Forráskód Böngészése

Cleanup: actually use WindowsVersionAtLeast.

Martijn Laan 1 éve
szülő
commit
e58973bbd4
3 módosított fájl, 23 hozzáadás és 17 törlés
  1. 0 12
      Projects/Src/InstFnc2.pas
  2. 2 2
      Projects/Src/Install.pas
  3. 21 3
      Projects/Src/Main.pas

+ 0 - 12
Projects/Src/InstFnc2.pas

@@ -26,18 +26,6 @@ uses
   Windows, SysUtils, PathFunc, CmnFunc2, InstFunc, Main, Msgs, MsgIDs,
   Windows, SysUtils, PathFunc, CmnFunc2, InstFunc, Main, Msgs, MsgIDs,
   ActiveX, ComObj, PropSys, ShellAPI, ShlObj;
   ActiveX, ComObj, PropSys, ShellAPI, ShlObj;
 
 
-function IsWindows8: Boolean;
-{ Returns True if running Windows 8 or later }
-begin
-  Result := (WindowsVersion >= Cardinal($06020000));
-end;
-
-function IsWindows10: Boolean;
-{ Returns True if running Windows 10 or later }
-begin
-  Result := (WindowsVersion >= Cardinal($0A000000));
-end;
-
 procedure AssignWorkingDir(const SL: IShellLink; const WorkingDir: String);
 procedure AssignWorkingDir(const SL: IShellLink; const WorkingDir: String);
 { Assigns the specified working directory to SL. If WorkingDir is empty then
 { Assigns the specified working directory to SL. If WorkingDir is empty then
   we select one ourself as best we can. (Leaving the working directory field
   we select one ourself as best we can. (Leaving the working directory field

+ 2 - 2
Projects/Src/Install.pas

@@ -721,7 +721,7 @@ var
       { ARP on Windows 7 without SP1 only pays attention to the lower 6 bytes of EstimatedSize and
       { ARP on Windows 7 without SP1 only pays attention to the lower 6 bytes of EstimatedSize and
         throws away the rest. For example putting in $4000001 (=4GB + 1KB) displays as 1 KB.
         throws away the rest. For example putting in $4000001 (=4GB + 1KB) displays as 1 KB.
         So we need to check for this. }
         So we need to check for this. }
-      if (Hi(NTServicePackLevel) > 0) or (WindowsVersion shr 16 > $0601) or (EstimatedSize.Hi = 0) then begin
+      if (Hi(NTServicePackLevel) > 0) or IsWindows8 or (EstimatedSize.Hi = 0) then begin
         Div64(EstimatedSize, 1024);
         Div64(EstimatedSize, 1024);
         SetDWordValue(H2, 'EstimatedSize', EstimatedSize.Lo)
         SetDWordValue(H2, 'EstimatedSize', EstimatedSize.Lo)
       end;
       end;
@@ -909,7 +909,7 @@ var
     var
     var
       RootKey, K: HKEY;
       RootKey, K: HKEY;
     begin
     begin
-      if PerUserFont and (WindowsVersion < Cardinal($0A0042EE)) then begin
+      if PerUserFont and not WindowsVersionAtLeast(10, 0, 17134) then begin
         { Per-user fonts require Windows 10 Version 1803 (10.0.17134) or newer. }
         { Per-user fonts require Windows 10 Version 1803 (10.0.17134) or newer. }
         if not WarnedPerUserFonts then begin
         if not WarnedPerUserFonts then begin
           Log('Failed to set value in Fonts registry key: per-user fonts are not supported by this version of Windows.');
           Log('Failed to set value in Fonts registry key: per-user fonts are not supported by this version of Windows.');

+ 21 - 3
Projects/Src/Main.pas

@@ -256,7 +256,10 @@ function ShouldProcessRunEntry(const WizardComponents, WizardTasks: TStringList;
   const RunEntry: PSetupRunEntry): Boolean;
   const RunEntry: PSetupRunEntry): Boolean;
 function TestPassword(const Password: String): Boolean;
 function TestPassword(const Password: String): Boolean;
 procedure UnloadSHFolderDLL;
 procedure UnloadSHFolderDLL;
-function WindowsVersionAtLeast(const AMajor, AMinor: Byte): Boolean;
+function WindowsVersionAtLeast(const AMajor, AMinor: Byte; const ABuild: Word = 0): Boolean;
+function IsWindows8: Boolean;
+function IsWindows10: Boolean;
+function IsWindows11: Boolean;
 
 
 implementation
 implementation
 
 
@@ -299,9 +302,24 @@ type
 
 
 { Misc. functions }
 { Misc. functions }
 
 
-function WindowsVersionAtLeast(const AMajor, AMinor: Byte): Boolean;
+function WindowsVersionAtLeast(const AMajor, AMinor: Byte; const ABuild: Word): Boolean;
 begin
 begin
-  Result := (WindowsVersion >= Cardinal((AMajor shl 24) or (AMinor shl 16)));
+  Result := WindowsVersion >= Cardinal((AMajor shl 24) or (AMinor shl 16) or ABuild);
+end;
+
+function IsWindows8: Boolean;
+begin
+  Result := WindowsVersionAtLeast(6, 2);
+end;
+
+function IsWindows10: Boolean;
+begin
+  Result := WindowsVersionAtLeast(10, 0);
+end;
+
+function IsWindows11: Boolean;
+begin
+  Result := WindowsVersionAtLeast(10, 0, 22000);
 end;
 end;
 
 
 function GetUninstallRegKeyBaseName(const ExpandedAppId: String): String;
 function GetUninstallRegKeyBaseName(const ExpandedAppId: String): String;