简体   繁体   中英

Checking for Windows Server 2003

I created theses functions for installing some files on windows server 2003, I want to know if this is the correct way.

function IsServer: Boolean;
var
  ver: TWindowsVersion;
begin
  GetWindowsVersionEx(ver);
  Result := UsingWinNT and (ver.Major = 5) and (ver.Minor >= 2) and Not IsWin64;
end;

function IsServer64: Boolean;
var
  ver: TWindowsVersion;
begin
  GetWindowsVersionEx(ver);
  Result := UsingWinNT and (ver.Major = 5) and (ver.Minor >= 2) and IsWin64;
end;

You didn't show us what UsingWinNT does - Though you definitely do not need to check for "NT" - Inno Setup-made installer won't even start on non-NT system.


IsServer64 will return true even on Windows XP Professional x64 Edition, as it also has 5.2 version .

To distinguish these, test ver.ProductType = VER_NT_SERVER .
See How to programmatically tell the difference between XP 64 bit and Server 2003 64 Bit


function IsWindowsServer2003_32Bit: Boolean;
var
  Ver: TWindowsVersion;
begin
  GetWindowsVersionEx(Ver);
  Result :=
    (Ver.ProductType = VER_NT_SERVER) and
    (Ver.Major = 5) and (Ver.Minor = 2) and (not IsWin64);
end;

function IsWindowsServer2003_64Bit: Boolean;
var
  Ver: TWindowsVersion;
begin
  GetWindowsVersionEx(Ver);
  Result :=
    (Ver.ProductType = VER_NT_SERVER) and
    (Ver.Major = 5) and (Ver.Minor = 2) and IsWin64;
end;

See also Determine Windows version in Inno Setup .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM