Sign in Join

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

Mailing lists / lazarus / 2001-02

[Fwd: 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
"Luis R. Hilario" wrote 65 lines
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.

Some made tests:
"If then" is working well.
If use "Writeln" before OpenKey, OpenKey does not open and creates a key and leaves with an error.

Example:
Writeln(SubKey);
if Not Reg.OpenKey(SubKey, True) then... // An error here.

|-----------------------------| | Luis R. Hilario | | http://www.luisdigital.2y.net | |-----------------------------| To: "" Subject: [lazarus] TRegistry: OpenKey, Access
Earlier message 85 lines
From: "Luis R. Hilario" Date: Thu, 01 Feb 2001 18:26:55 -0300 Organization: Luis Digital Reply-To: Resent-Date: Thu, 1 Feb 2001 17:44:53 -0500 Resent-From: Resent-Message-ID: Resent-Sender: Sender: 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 | |-----------------------------| _________________________________________________________________ To unsubscribe: mail with "unsubscribe" as the Subject archives at http://www.miraclec.com/list_archives/lazarus

Reply by email