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

时间:2013-08-28 12:16:38

标签: inno-setup

我正在使用Inno来创建设置文件。我一直在检测我的操作系统类型。有谁知道如何检查我的操作系统是否是Windows XP或更高版本?

2 个答案:

答案 0 :(得分:1)

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;  

<强>更新
 尝试一下这个陈述。这将在文件中存储所需的系统信息。您可以使用 Loadstringsfromfile tarraystrings ,然后使用您想要的方式。

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);

答案 1 :(得分:1)

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

[Setup]
MinVersion=0,6.01

这将阻止安装程序在早于XP的任何内容上运行。

或者,您可以使用以下内容对单个文件执行相同的操作:

Source: ...; MinVersion: 0,6.01

^将仅在XP或更高版本上安装文件

Source: ...; OnlyBelowVersion: 0,6.01

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

相关问题