1

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

4

2 回答 2

2

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

[Setup]
MinVersion=0,6.01

这将阻止安装程序在 XP 之前的任何设备上运行。

Alternatively you can do the same thing for individual files by using something like this:

Source: ...; MinVersion: 0,6.01

^ will install the file only on XP or above

Source: ...; OnlyBelowVersion: 0,6.01

^ will install the file only on pre-XP versions

于 2013-08-28T20:49:52.860 回答
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;  

更新:
试试这个语句。这会将所需的系统信息存储在一个文件中。您可以使用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);
于 2013-08-28T13:34:56.157 回答