2016-07-18 18 views
3

恆{PF}兩個32位/ 64位系統目錄是Inno Setup的:使用 「程序文件」 與{PF}

目錄C:\ Program Files文件

爲32位系統和

C:\ Program Files文件(x86)的

64位SY莖。

不過,我想使用的目錄

C:\ Program Files文件

兩個,32位和64位系統。我怎樣才能做到這一點?

+0

'{PF}'擴展到本地程序文件目錄(* C:\ Program Files文件*默認情況下),除非你正在運行在64位的32位安裝程序OS。對於32位安裝程序,您可以使用「{pf64}」(這會在32位操作系統上引發異常),但創建64位安裝程序可能更容易。 – IInspectable

+0

我該如何做到這一點?這是因爲我需要將文件安裝在C:\ Program Files目錄中,但它也應該用於32位和64位... –

+0

如果您希望將程序安裝到64位的* C:\ Program Files *中位版本的Windows,您應該創建一個64位安裝程序,並使用'{pf}',就像您在32位安裝程序中那樣。現在您只需確保您的32位安裝程序不能在64位版本的Windows上運行。 – IInspectable

回答

2

使用scripted constant,如:

[Setup] 
DefaultDirName={code:GetProgramFiles}\My Program 

[Code] 

function GetProgramFiles(Param: string): string; 
begin 
    if IsWin64 then Result := ExpandConstant('{pf64}') 
    else Result := ExpandConstant('{pf32}') 
end; 

雖然這種做法只應使用,如果您生成在飛行各個平臺的二進制文件。就像你的情況一樣,如果理解正確,你可以爲相應的體系結構編譯Java二進制文件。


如果你在安裝一個單獨的32位和64位二進制文​​件,請使用類似的腳本:

[Files] 
Source: "MyDll32.dll"; DestDir: "{pf32}\My Program"; Check: not IsWin64 
Source: "MyDll64.dll"; DestDir: "{pf64}\My Program"; Check: IsWin64 

參見:

1

如果您使用單一安裝程序進行64位和32位安裝,那麼您應該使用ArchitecturesInstallIn64BitMode設置指令。這將改變{pf}和其他腳本常量在64位系統上安裝時的64位版本,以及在32位系統上安裝時的32位版本。

你很明顯也想用Martin的例子中的Check來確保你只安裝正確的二進制文件。

例:

#define MyAppName "MyAwesomeApp" 
[Setup] 
ArchitecturesInstallIn64BitMode=x64 
AppName={#MyAppName} 
DefaultDirname={pf}\{#MyAppName} 

[Files] 
Source: "MyApp_32bit.exe"; DestDir: "{app}"; Check not Is64BitinstallMode; 
Source: "MyApp_64bit.exe"; DestDir: "{app}"; Check Is64BitinstallMode;