Przeglądaj źródła

* Merging revisions 44429 from trunk:
------------------------------------------------------------------------
r44429 | michael | 2020-03-30 11:26:02 +0200 (Mon, 30 Mar 2020) | 1 line

* Patch from Bart Broersma to fix bug ID #36809
------------------------------------------------------------------------

git-svn-id: branches/fixes_3_2@44430 -

michael 5 lat temu
rodzic
commit
525d1c5ed5
1 zmienionych plików z 6 dodań i 2 usunięć
  1. 6 2
      packages/fcl-registry/src/winreg.inc

+ 6 - 2
packages/fcl-registry/src/winreg.inc

@@ -335,7 +335,7 @@ var
 
 begin
   Result:=nil;
-  if GetKeyInfo(Info) then
+  if GetKeyInfo(Info) and (Info.NumSubKeys > 0) then
   begin
     dwLen:=Info.MaxSubKeyLen+1;
     GetMem(lpName,dwLen*SizeOf(WideChar));
@@ -346,6 +346,8 @@ begin
       begin
         dwLen:=Info.MaxSubKeyLen+1;
         lResult:=RegEnumKeyExW(CurrentKey,dwIndex,lpName,dwLen,Nil,Nil,Nil,Nil);
+        if lResult=ERROR_NO_MORE_ITEMS then
+          Break;
         if lResult<>ERROR_SUCCESS then
           raise ERegistryException.Create(SysErrorMessage(lResult));
         if dwLen=0 then
@@ -375,7 +377,7 @@ var
 
 begin
   Result:=nil;
-  if GetKeyInfo(Info) then
+  if GetKeyInfo(Info) and (Info.NumValues > 0) then
   begin
     dwLen:=Info.MaxValueLen+1;
     GetMem(lpName,dwLen*SizeOf(WideChar));
@@ -385,6 +387,8 @@ begin
       begin
         dwLen:=Info.MaxValueLen+1;
         lResult:=RegEnumValueW(CurrentKey,dwIndex,lpName,dwLen,Nil,Nil,Nil,Nil);
+        if lResult=ERROR_NO_MORE_ITEMS then
+          Break;
         if lResult<>ERROR_SUCCESS then
           raise ERegistryException.Create(SysErrorMessage(lResult));
         if dwLen=0 then