Inno setup Inno设置StringChangeEx失败

Inno setup Inno设置StringChangeEx失败,inno-setup,Inno Setup,我正在使用Inno安装脚本在64位安装中安装32位和64位DLL。我可以从注册表设置中获取64位路径,但缺少的32位路径不存在。但是,我知道路径的“尾部”是恒定的,只是头部需要修改。即 64-bit (from registry) = c:\Program Files\My Application\Bin 32-bit (derived) = c:\Program Files (x86)\My Application\Bin 所以我要做的就是用32位的路径替换掉64位的程序文件路径

我正在使用Inno安装脚本在64位安装中安装32位和64位DLL。我可以从注册表设置中获取64位路径,但缺少的32位路径不存在。但是,我知道路径的“尾部”是恒定的,只是头部需要修改。即

64-bit (from registry) = c:\Program Files\My Application\Bin
32-bit (derived)       = c:\Program Files (x86)\My Application\Bin
所以我要做的就是用32位的路径替换掉64位的程序文件路径。我使用StringChangeEx很容易做到这一点:

RegQueryStringValue(HKLM, 'SOFTWARE\My Application', 'RootDir', sPath)
if IsWin64() then
  StringChangeEx(sPath, ExpandConstant('{pf}'), ExpandConstant('{pf32}'), False);
sPath与我的32位路径一起返回。这在大多数系统上都非常有效,但有时StringChangeEx似乎不会将“C:\Program Files”替换为“C:\Program Files(x86)”。我已经(使用MsgBox)验证了{pf}和{pf32}常量是我所认为的。大小写相同,没有前导/尾随空格。似乎在某些系统上,该功能不起作用


我正在使用最新版本的InnoSetup(10/2010)。网站没有提到这个功能有任何问题。有没有其他人看到过这个,或者对它可能是什么有什么想法?

我把这个小脚本拼凑起来,使用5.4.0(2010年10月发行版),它工作了:

; 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选项,但代码不会自动记录。您需要添加日志(const S:String)调用

结果表明注册表项有时有小写的驱动器号。我将代码更改为:

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

我假设注册表项不是问题所在,但不是问题所在。

问题在于注册表的大小写与{pf}不同。因此,几个小写()调用就成功了。/log选项在前面确实对我有所帮助,因为它引导我找到了这段代码。不过,可能真的使用了某种Inno调试器。