2013-08-28 57 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

相關問題