Inno Setup StringChangeEx失败
我正在使用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)。该网站没有提到这个功能的任何问题。有没有其他人看到过这个和/或对它有什么想法?
原来,注册表项有时有一个小写的驱动器号。我将代码更改为:
RegQueryStringValue(HKLM, 'SOFTWARE\My Application', 'RootDir', sPath)
sPath := Lowercase(sPath);
if IsWin64() then
StringChangeEx(sPath, Lowercase(ExpandConstant('{pf}')), Lowercase(ExpandConstant('{pf32}')), False)
我假定注册表项不是问题,但不是那么回事。
我扔在一起,这个小脚本,并使用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:字符串)调用。
问题原来是注册表没有像{pf}完全一样。所以几个小写()调用就完成了。/log选项的确帮助了我,因为它将我引向了这部分代码。虽然可以真的使用某种Inno调试器。 – 2011-01-25 18:00:44
如果解决了您的问题,请接受此答案。 – Bernard 2011-01-25 19:21:59