* To be Delphi compatible TRegistry.DeleteKey() must delete the specified key and all its child keys.

git-svn-id: trunk@48207 -
(cherry picked from commit ffff24593d)
This commit is contained in:
yury 2021-01-19 17:21:18 +00:00 committed by florian
parent bade890df5
commit 324061745a

View File

@ -70,7 +70,28 @@ function TRegistry.DeleteKey(const Key: UnicodeString): Boolean;
Var
u: UnicodeString;
subkeys: TUnicodeStringArray;
k, old: HKEY;
i: integer;
begin
old:=fCurrentKey;
k:=GetKey(Key);
if k <> 0 then
begin
fCurrentKey:=k;
try
subkeys:=GetKeyNames;
for i:=0 to High(subkeys) do
begin
Result:=DeleteKey(subkeys[i]);
if not Result then
exit;
end;
finally
fCurrentKey:=old;
CloseKey(k);
end;
end;
u:=PRepKey(Key);
FLastError:=RegDeleteKeyW(GetBaseKey(RelativeKey(Key)),PWideChar(u));
Result:=FLastError=ERROR_SUCCESS;