使用 Inno Setup Pascal 脚本检查当前 OS 是否为 Windows 8.1

Check if the current OS is Windows 8.1 using Inno Setup Pascal Script

我想判断当前的OS是不是Windows8.1.

我知道这可以通过分析当前 Windows 版本的 NT 版本号 (6.3) 来解决,但我不知道如何在Pascal 脚本。

伪代码:

// Occurs when the installer initializes.
function InitializeSetup(): Boolean;
begin
  if IsWindows81 then
    begin
      Result := IsKBInstalled('KB2919355');
      if not Result then
        MsgBox('Windows Update package "KB2919355" not found.', mbError, MB_OK);
      end;
    else
      begin
        Result := True
      end;
end;

Windows 8.1 是 Windows version 6.3.

最简单的是检查GetWindowsVersion function的return值,即$MMNNBBBBMajor,miN或者,Build).

function IsWindows81OrLater: Boolean;
begin
  Result := (GetWindowsVersion >= 030000);
end;

如果您只想检查 Windows 8.1,请使用:

function IsWindows81: Boolean;
begin
  Result := (GetWindowsVersion >= 030000) and (GetWindowsVersion <= 03FFFF);
end;