scripting - 如何使用 Inno Setup 根据注册表项选择性地在文件夹中安装插件/文件?

标签 scripting registry inno-setup

Inno Setup是一个很好用的安装程序。评分较高this stackoverflow question 。我需要将插件安装到与第 3 方应用程序的安装文件夹相关的文件夹中。从文档中来看,如何做到这一点并不明显。

最佳答案

您可以在文档和示例代码中找到如何使用注册表项选择性安装文件的答案,但这可能并不明显,因此这里有一些使用 Adob​​e Premiere 插件作为示例的示例脚本片段:

关键步骤是:

1)使用Check:参数

2) 编写一个函数,调用 RegQueryStringValue 并解析路径以构造相对的插件文件夹目标

3) 使用 {code:} 调用函数返回目标文件夹

//
// Copy my plugin file to the Premiere Plugin folder, but only if Premiere is installed.
//
[Files]
Source: "C:\sourceFiles\myplugin.prm";  Check: GetPremierePluginDestination; DestDir: "{code:PluginDestination}"; Flags: ignoreversion overwritereadonly

[Code]

var sPluginDest : String;

//
// Search for the path where Premiere Pro was installed.  Return true if path found.
// Set variable to plugin folder
//

function GetPremierePluginDestination(): Boolean;
var
  i:      Integer;
  len:    Integer;

begin
  sPluginDest := '';

  RegQueryStringValue( HKLM, 'SOFTWARE\Adobe\Premiere Pro\CurrentVersion', 'Plug-InsDir', sPluginDest );
  len := Length(sPluginDest);
  if len > 0 then
  begin
    i := len;
    while sPluginDest[i] <> '\' do
      begin
        i := i-1;
      end;

    i := i+1;
    Delete(sPluginDest, i, Len-i+1);
    Insert('Common', sPluginDest, i);
  end;
  Result := len > 0;
end;

//
//  Use this function to return path to install plugin
//
function PluginDestination(Param: String) : String;
begin
   Result := sPluginDest;
end;

我不是 Pascal 程序员,因此欢迎提出有关使 GetPremiereDestination 更高效的建议。

关于scripting - 如何使用 Inno Setup 根据注册表项选择性地在文件夹中安装插件/文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/121812/

相关文章:

perl - Perl 提供了哪些其他语言没有的编译时功能?

linux - 使用具有多个替换命令的脚本时控制 sed 输出

delphi - 注册表 "forgetting"值

c# - 用于注册 ActiveX 的 .INF 文件问题

windows - 创新设置: How to change uninstall background color

inno-setup - 使用 innosetup 中的函数添加注册表项

c# - 软件 GUID 是否应该与程序集 GUID 不同?

bash - 如何为 curl 命令对数据进行 urlencode?

scripting - Adobe Premiere 脚本

registry - 对注册表项感到困惑