Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2001-02

TRegistry: OpenKey, Access

1 message · 1 person ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Luis R. Hilario

Hi,

New: property Access.

I am also working with: OpenKey, but I have a problem. OpenKey is not complete, but it works:

function TRegistry.OpenKey(const Key: string; CanCreate: Boolean):
Boolean;
Var
  KeyP: PChar;
  PHandle: PHKEY;
  Disposition: LPDWord;
  SecurityAttributes: LPSECURITY_ATTRIBUTES;
begin
KeyP := @Key[1];
SecurityAttributes := Null;

If CanCreate then

   Result := RegCreateKeyEx(fRootKey,
                            KeyP,
                            0,
                            '',
                            REG_OPTION_NON_VOLATILE,
                            fAccess,
                            SecurityAttributes,
                            PHandle,
                            Disposition) = ERROR_SUCCESS else
   Result := RegOpenKeyEx(fRootKey,
                          KeyP,
                          0,
                          fAccess,
                          PHandle) = ERROR_SUCCESS;
If Result then fCurrentKey := PHandle^;
end;

The problem is with the test program:

if Not Reg.OpenKey(SubKey, True) then         // If it happens an error
the following lines they execute...
    Writeln('Error Abriendo Key: ', SubKey);  // ...if there is no an
error the following lines not they execute.
    Writeln(Reg.CurrentKey, '/', Reg.RootKey);
    Reg.CloseKey;
    Reg.free;
    Writeln(Reg.CurrentKey, '/', Reg.RootKey);

It is working like:

if Not Reg.OpenKey(SubKey, True) then
  Begin                                 // <--- OjO (Eye :)
    Writeln('Error Abriendo Key: ', SubKey);
    Writeln(Reg.CurrentKey, '/', Reg.RootKey);
    Reg.CloseKey;
    Reg.free;
    Writeln(Reg.CurrentKey, '/', Reg.RootKey);
  end;                                  // <--- OjO

Somebody knows what is happening here?

I am going to change to Winbug and to prove something, but any aid is appreciated.

|-----------------------------| | Luis R. Hilario | | http://www.luisdigital.2y.net | |-----------------------------|

Reply by email