mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-12-04 22:30:52 +01:00
* Implemented CurrentPath property.
* Fixed handle leak when calling OpenKey() for already opened registry. git-svn-id: trunk@22652 -
This commit is contained in:
parent
8b63363878
commit
7607cc06de
@ -177,7 +177,7 @@ Var
|
||||
Handle: HKEY;
|
||||
Disposition: Integer;
|
||||
SecurityAttributes: Pointer; //LPSECURITY_ATTRIBUTES;
|
||||
|
||||
S: string;
|
||||
begin
|
||||
SecurityAttributes := Nil;
|
||||
P:=PrepKey(Key);
|
||||
@ -194,21 +194,27 @@ begin
|
||||
else
|
||||
Result:=RegOpenKeyExA(GetBaseKey(RelativeKey(Key)),
|
||||
P,0,fAccess,Handle)=ERROR_SUCCESS;
|
||||
If Result then
|
||||
fCurrentKey:=Handle;
|
||||
If Result then begin
|
||||
if RelativeKey(Key) then
|
||||
S:=CurrentPath + Key
|
||||
else
|
||||
S:=P;
|
||||
ChangeKey(Handle, S);
|
||||
end;
|
||||
end;
|
||||
|
||||
function TRegistry.OpenKeyReadOnly(const Key: string): Boolean;
|
||||
|
||||
Var
|
||||
P: PChar;
|
||||
Handle: HKEY;
|
||||
|
||||
OldAccess: LongWord;
|
||||
begin
|
||||
P:=PrepKey(Key);
|
||||
Result := RegOpenKeyExA(GetBaseKey(RelativeKey(Key)),P,0,KEY_READ,Handle) = 0;
|
||||
If Result Then
|
||||
fCurrentKey := Handle;
|
||||
OldAccess:=fAccess;
|
||||
fAccess:=KEY_READ;
|
||||
try
|
||||
Result:=OpenKey(Key, False);
|
||||
finally
|
||||
fAccess:=OldAccess;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TRegistry.RegistryConnect(const UNCName: string): Boolean;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user