[lazarus] TRegistry: OpenKey, Access

Luis R. Hilario luis at luis-digital.8m.com
Thu Feb 1 17:44:52 EST 2001


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 |
 |-----------------------------|






More information about the Lazarus mailing list