Browse Source

Cleanup: actually use WindowsVersionAtLeast.

Martijn Laan 1 year ago
parent
commit
e58973bbd4
3 changed files with 23 additions and 17 deletions
  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,
   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);
 { 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

+ 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
         throws away the rest. For example putting in $4000001 (=4GB + 1KB) displays as 1 KB.
         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);
         SetDWordValue(H2, 'EstimatedSize', EstimatedSize.Lo)
       end;
@@ -909,7 +909,7 @@ var
     var
       RootKey, K: HKEY;
     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. }
         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.');

+ 21 - 3
Projects/Src/Main.pas

@@ -256,7 +256,10 @@ function ShouldProcessRunEntry(const WizardComponents, WizardTasks: TStringList;
   const RunEntry: PSetupRunEntry): Boolean;
 function TestPassword(const Password: String): Boolean;
 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
 
@@ -299,9 +302,24 @@ type
 
 { Misc. functions }
 
-function WindowsVersionAtLeast(const AMajor, AMinor: Byte): Boolean;
+function WindowsVersionAtLeast(const AMajor, AMinor: Byte; const ABuild: Word): Boolean;
 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;
 
 function GetUninstallRegKeyBaseName(const ExpandedAppId: String): String;