Checking for Windows Server 2003

风格不统一 提交于 2019-12-23 01:54:32

问题


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;

回答1:


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.



来源:https://stackoverflow.com/questions/53561203/checking-for-windows-server-2003

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!