|
@@ -1,3 +1,9 @@
|
|
|
|
+type
|
|
|
|
+ TWinRegData = record
|
|
|
|
+ RootKeyOwned: Boolean;
|
|
|
|
+ end;
|
|
|
|
+ PWinRegData = ^TWinRegData;
|
|
|
|
+
|
|
{******************************************************************************
|
|
{******************************************************************************
|
|
TRegistry
|
|
TRegistry
|
|
******************************************************************************}
|
|
******************************************************************************}
|
|
@@ -5,11 +11,16 @@
|
|
Procedure TRegistry.SysRegCreate;
|
|
Procedure TRegistry.SysRegCreate;
|
|
begin
|
|
begin
|
|
FStringSizeIncludesNull:=True;
|
|
FStringSizeIncludesNull:=True;
|
|
|
|
+ New(PWinRegData(FSysData));
|
|
|
|
+ PWinRegData(FSysData)^.RootKeyOwned := False;
|
|
end;
|
|
end;
|
|
|
|
|
|
Procedure TRegistry.SysRegfree;
|
|
Procedure TRegistry.SysRegfree;
|
|
|
|
|
|
begin
|
|
begin
|
|
|
|
+ if PWinRegData(FSysData)^.RootKeyOwned and (RootKey <> 0) then
|
|
|
|
+ RegCloseKey(RootKey);
|
|
|
|
+ Dispose(PWinRegData(FSysData));
|
|
end;
|
|
end;
|
|
|
|
|
|
Function PrepKey(Const S : String) : pChar;
|
|
Function PrepKey(Const S : String) : pChar;
|
|
@@ -219,8 +230,20 @@ begin
|
|
end;
|
|
end;
|
|
|
|
|
|
function TRegistry.RegistryConnect(const UNCName: string): Boolean;
|
|
function TRegistry.RegistryConnect(const UNCName: string): Boolean;
|
|
|
|
+{$ifndef WinCE}
|
|
|
|
+var
|
|
|
|
+ newroot: HKEY;
|
|
|
|
+{$endif}
|
|
begin
|
|
begin
|
|
- Result := False;
|
|
|
|
|
|
+{$ifdef WinCE}
|
|
|
|
+ Result:=False;
|
|
|
|
+{$else}
|
|
|
|
+ Result:=RegConnectRegistryA(PChar(UNCName),RootKey,newroot)=ERROR_SUCCESS;
|
|
|
|
+ if Result then begin
|
|
|
|
+ RootKey:=newroot;
|
|
|
|
+ PWinRegData(FSysData)^.RootKeyOwned:=True;
|
|
|
|
+ end;
|
|
|
|
+{$endif}
|
|
end;
|
|
end;
|
|
|
|
|
|
function TRegistry.ReplaceKey(const Key, FileName, BackUpFileName: string): Boolean;
|
|
function TRegistry.ReplaceKey(const Key, FileName, BackUpFileName: string): Boolean;
|
|
@@ -384,6 +407,13 @@ end;
|
|
|
|
|
|
procedure TRegistry.SetRootKey(Value: HKEY);
|
|
procedure TRegistry.SetRootKey(Value: HKEY);
|
|
begin
|
|
begin
|
|
|
|
+ if fRootKey = Value then
|
|
|
|
+ Exit;
|
|
|
|
+ { close a root key that was opened using RegistryConnect }
|
|
|
|
+ if PWinRegData(FSysData)^.RootKeyOwned and (fRootKey <> 0) then begin
|
|
|
|
+ RegCloseKey(fRootKey);
|
|
|
|
+ PWinRegData(FSysData)^.RootKeyOwned := False;
|
|
|
|
+ end;
|
|
fRootKey := Value;
|
|
fRootKey := Value;
|
|
end;
|
|
end;
|
|
|
|
|