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.