Inno setup 如何从inno检查我的操作系统是否为windows xp或更高版本

Inno setup 如何从inno检查我的操作系统是否为windows xp或更高版本,inno-setup,Inno Setup,我正在使用Inno创建一个安装文件。我一直在检测我的操作系统类型。有人知道如何检查我的操作系统是Windows XP还是更高版本吗?GetWindowsVersionEx请参阅inno安装帮助文件中的此功能 检查此代码是否适用于您 procedure Initializewizard; begin { GetWindowsVersionEx(Version); //windows version information //5.0.2195 Windows 2000 //5.1.26

我正在使用Inno创建一个安装文件。我一直在检测我的操作系统类型。有人知道如何检查我的操作系统是Windows XP还是更高版本吗?

GetWindowsVersionEx请参阅inno安装帮助文件中的此功能

检查此代码是否适用于您

procedure Initializewizard;
begin
{
  GetWindowsVersionEx(Version);



//windows version information
//5.0.2195 Windows 2000 
//5.1.2600 Windows XP or Windows XP 64-Bit Edition Version 2002 (Itanium) 
//5.2.3790 Windows Server 2003 or Windows XP x64 Edition (AMD64/EM64T) or Windows XP 64-Bit Edition Version 2003 (Itanium) 
//6.0.6000 Windows Vista 
//6.1.7600 Windows 7 or Windows Server 2008 R2  
//6.2.9200 Windows 8 or Windows Server 2012 
//Note that there is normally no need to specify the build numbers (i.e., you may simply use "5.1" for Windows XP).


  if (Version.Major = 5) and
     (Version.Minor = 0) then
  Msgbox('THIS IS Windows 2000 EDITION', mbInformation,MB_OK)
    if (Version.Major = 5) and
     (Version.Minor = 1) then
  Msgbox('THIS IS Windows XP or Windows XP 64-Bit Edition Version 2002 (Itanium)  ', mbInformation,MB_OK)
  if (Version.Major = 5) and
     (Version.Minor = 2) then
  Msgbox('THIS IS Windows Server 2003 or Windows XP x64 Edition (AMD64/EM64T) or Windows XP 64-Bit Edition Version 2003 (Itanium) ', mbInformation,MB_OK)

  if (Version.Major = 6) and
     (Version.Minor = 0) then
  Msgbox('THIS IS Windows VistaEDITION', mbInformation,MB_OK)

  if (Version.Major = 6) and
  (Version.Minor = 1) then
  Msgbox('THIS IS Windows 7 or Windows Server 2008 R2 EDITION', mbInformation,MB_OK)

  if (Version.Major = 6) and
     (Version.Minor = 2) then
  Msgbox('THIS IS Windows 8 or Windows Server 2012 EDITION', mbInformation,MB_OK )
      }
  end;  
更新:
试试这个说法。这将在文件中存储所需的系统信息。您可以使用Loadstringsfromfiletarraystrings,然后根据需要使用

Exec('cmd.exe', '/C systeminfo| findstr "OS Name: OS Version: OS Build Type: System Manufacturer: System Model: System Type: Processor(s): Total Physical Memory: Available Physical Memory: Virtual Memory: Max Size: Virtual Memory: Available: Virtual Memory: In Use:" |find /v /i "vmware" |find /v "Hotfix" | find /v "BIOS" |find /v "Locale" |find /v "Directory" |find /v /i "configuration"|find /v "Host Name"|find /v "Connection" |find /v "Date" |find /v "Boot" |find /v "Corporation" > "' + TmpFileName + '"', '', SW_HIDE,ewWaitUntilTerminated, ResultCode);

如果您想这样做是因为XP是您所需的Windows最低版本,那么您可以使用:

[Setup]
MinVersion=0,6.01
这将阻止安装程序在XP之前的任何设备上运行

或者,您也可以对单个文件执行相同的操作,方法如下:

Source: ...; MinVersion: 0,6.01
^将仅在XP或更高版本上安装该文件

Source: ...; OnlyBelowVersion: 0,6.01

^将仅在XP之前的版本上安装该文件

可能的副本,或者如果您需要从代码中测试该文件,您可以使用功能参考中显示的示例。