【问题标题】:Inno Setup StringChangeEx FailureInno 设置 StringChangeEx 失败
【发布时间】:2011-01-25 15:48:13
【问题描述】:

我正在使用 Inno Setup 脚本在 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

所以我所做的就是将 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' 换成 'C:\Program Files (x86)'。我已经验证(使用 MsgBox){pf} 和 {pf32} 常量是我认为的。大小写相同,并且没有前导/尾随空格。似乎在某些系统上,该功能不起作用。

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

【问题讨论】:

    标签: inno-setup


    【解决方案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 选项,但不会自动记录代码。您需要添加 Log(const S: String) 调用。

    【讨论】:

    • 问题原来是注册表的大小写不完全像 {pf}。所以几个小写()调用就可以了。 /log 选项之前确实对我有所帮助,因为它引导我进入了这部分代码。不过,真的可以使用某种 Inno-debugger。
    【解决方案2】:

    原来,注册表项有时有一个小写的驱动器号。我将代码更改为:

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

    我原以为注册表项不是问题,但事实并非如此。

    【讨论】:

      猜你喜欢
      • 2017-01-24
      • 2011-12-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-02-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多