Ala*_*ley 1 registry scripting inno-setup
Inno Setup是一个易于使用的好安装程序。在这个stackoverflow问题中被评为高分。我需要将插件安装到相对于第三方应用程序的安装文件夹的文件夹中。从文档中如何做到这一点并不明显。
您可以在文档和示例代码中找到有关使用注册表项选择安装文件的方法的答案,但可能并不明显,因此这里有一些示例脚本片段,其中使用Adobe 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;
Run Code Online (Sandbox Code Playgroud)
我不是Pascal程序员,所以欢迎提出任何有关使GetPremiereDestination更有效率的建议。
| 归档时间: |
|
| 查看次数: |
3583 次 |
| 最近记录: |