Browse Source

Correcting NoDrives reading logic

Source commit: 4389b963225c29cc2c228aed28e01dd017c8c57d
Martin Prikryl 1 năm trước cách đây
mục cha
commit
1f40ca7f72
1 tập tin đã thay đổi với 18 bổ sung8 xóa
  1. 18 8
      source/packages/filemng/IEDriveInfo.pas

+ 18 - 8
source/packages/filemng/IEDriveInfo.pas

@@ -405,20 +405,30 @@ var
   Reg: TRegistry;
   Folder: TSpecialFolder;
   Drives: string;
+  DrivesDataInfo: TRegDataInfo;
+const
+  NoDrivesValueName = 'NoDrives';
 begin
   AppLog('Loading drives');
-  FNoDrives := 0;
   Reg := TRegistry.Create;
+  FNoDrives := 0;
   try
-    if Reg.OpenKeyReadOnly('Software\Microsoft\Windows\CurrentVersion\Policies\Explorer') Then
-       Reg.ReadBinaryData('NoDrives', FNoDrives, SizeOf(FNoDrives));
-  except
-    try
-      FNoDrives := Reg.ReadInteger('NoDrives');
-    except
+    if Reg.OpenKeyReadOnly('Software\Microsoft\Windows\CurrentVersion\Policies\Explorer') and
+       Reg.GetDataInfo(NoDrivesValueName, DrivesDataInfo) then
+    begin
+      if (DrivesDataInfo.RegData = rdBinary) and (DrivesDataInfo.DataSize >= SizeOf(FNoDrives)) then
+      begin
+        Reg.ReadBinaryData(NoDrivesValueName, FNoDrives, SizeOf(FNoDrives));
+      end
+        else
+      if DrivesDataInfo.RegData = rdInteger then
+      begin
+        FNoDrives := Reg.ReadInteger(NoDrivesValueName);
+      end;
     end;
+  finally
+    Reg.Free;
   end;
-  Reg.Free;
   AppLog(Format('NoDrives mask: %d', [Integer(FNoDrives)]));
 
   FDesktop := nil;