2011-01-25 251 views
0

我正在使用Inno Setup腳本在64位安裝中安裝我的32位和64位DLL。我可以從註冊表設置中獲取64位路徑,但缺少32位路徑不存在。但是,我知道路徑的「尾巴」是不變的,只是頭部需要修改。即,Inno Setup StringChangeEx失敗

64-bit (from registry) = c:\Program Files\My Application\Bin 
32-bit (derived)  = c:\Program Files (x86)\My Application\Bin 

所以我做的是換出64位程序文件路徑與32位之一。我用StringChangeEx很容易地做到這一點:

RegQueryStringValue(HKLM, 'SOFTWARE\My Application', 'RootDir', sPath) 
if IsWin64() then 
    StringChangeEx(sPath, ExpandConstant('{pf}'), ExpandConstant('{pf32}'), False); 

sPath與我的32位路徑一起返回。這在大多數系統上都能很好地工作,但是似乎StringChangeEx並沒有爲'C:\ Program Files(x86)'換出'C:\ Program Files'。我已經驗證(使用MsgBox的){​​pf}和{pf32}常量是我認爲他們是。外殼是一樣的,沒有前/後空格。似乎在某些系統上,該功能不起作用。

我正在使用最新版本的InnoSetup(10/2010)。該網站沒有提到這個功能的任何問題。有沒有其他人看到過這個和/或對它有什麼想法?

回答

0

原來,註冊表項有時有一個小寫的驅動器號。我將代碼更改爲:

RegQueryStringValue(HKLM, 'SOFTWARE\My Application', 'RootDir', sPath) 
sPath := Lowercase(sPath); 
if IsWin64() then 
    StringChangeEx(sPath, Lowercase(ExpandConstant('{pf}')), Lowercase(ExpandConstant('{pf32}')), False) 

我假定註冊表項不是問題,但不是那麼回事。

+0

如果解決了您的問題,請接受此答案。 – Bernard 2011-01-25 19:21:59

1

我扔在一起,這個小腳本,並使用5.4.0(10/2010版本),它的工作:

; Script generated by the Inno Setup Script Wizard. 
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! 

[Setup] 
; NOTE: The value of AppId uniquely identifies this application. 
; Do not use the same AppId value in installers for other applications. 
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.) 
AppId={{AE1A6BBB-7582-43AA-85F5-C7F984D1A68B} 
AppName=My Program 
AppVersion=1.5 
;AppVerName=My Program 1.5 
AppPublisher=My Company, Inc. 
AppPublisherURL=http://www.example.com/ 
AppSupportURL=http://www.example.com/ 
AppUpdatesURL=http://www.example.com/ 
DefaultDirName={pf}\My Program 
DefaultGroupName=My Program 
OutputBaseFilename=setup 
Compression=lzma 
SolidCompression=yes 

[Code] 
function InitializeSetup(): Boolean; 

var 
sPath : string; 

begin 
sPath := ExpandConstant('{pf}') + '\mypath'; 
if IsWin64() then 
    StringChangeEx(sPath, ExpandConstant('{pf}'), ExpandConstant('{pf32}'), False); 
MsgBox(sPath, mbInformation, MB_OK); 
result := true; 

end; 

我的腳本可以工作或不適合你?
在你調用StringChangeEx之前sPath是否正確?

我會建議/ LOG選項,但代碼不會自動記錄。您需要添加日誌(常量S:字符串)調用。

+0

問題原來是註冊表沒有像{pf}完全一樣。所以幾個小寫()調用就完成了。/log選項的確幫助了我,因爲它將我引向了這部分代碼。雖然可以真的使用某種Inno調試器。 – 2011-01-25 18:00:44