2013-08-28 34 views
1

我使用的Inno用于创建自定义更高,安装文件,我被困在从中检测我的操作系统类型, 没有人知道如何检查我的操作系统是Windows XP中或更高版本的Windows。如何检查我的操作系统是Windows XP或从INNO

谢谢。

+2

可能重复[确定Windows版本在Inno安装](http://stackoverflow.com/questions/5849917/determine-windows-version-in-inno-setup) – Jon

回答

1

GetWindowsVersionEx看到这个函数在Inno Setup的帮助文件

检查这个代码将用于

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; 

你更新工作:
给一个尝试这种说法。这将存储在file.you所需的系统信息可以使用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); 
+0

我认为它会工作 – Nibin

1

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

[Setup] 
MinVersion=0,6.01 

,这将阻止安装程序从什么比XP运行旧。

或者,你可以使用这样的事情做对单个文件同样的事情:

Source: ...; MinVersion: 0,6.01 
只有

^将只安装在XP或以上的文件

Source: ...; OnlyBelowVersion: 0,6.01 

^将安装文件在XP以前的版本

+0

或者,如果你需要从代码测试这一点,你可以使用例如在['GetWindowsVersion'](http://www.jrsoftware.org/ishelp/index.php?topic=isxfunc_getwindowsversion)功能参考所示的示例。 – TLama

相关问题