我有一个安装项目,可以安装三个不同的可执行文件。
我想让用户可以选择将多个文件扩展名与其中一个exes或其中任何一个相关联。这有可能,如果是这样的话?
我目前用于将单个程序与文件扩展名关联的代码是:
[Registry]
Root: HKCR; Subkey: "program1\DefaultIcon"; ValueType: string; \
ValueName: ""; ValueData: "{app}\program1.EXE,0"
Root: HKCR; Subkey: "program1\shell\open\command"; ValueType: string; \
ValueName: ""; ValueData: """{app}\program1.exe"" ""%1"""
答案 0 :(得分:3)
您可以使用"Tasks"来展示选择。
例如:
[Tasks]
Name: associate; Description: "Associate application with extension"
Name: associate\app1; Description: "Application 1"; Flags: exclusive
Name: associate\app2; Description: "Application 2"; Flags: exclusive unchecked
Name: associate\app3; Description: "Application 3"; Flags: exclusive unchecked
然后使用相应部分中的Task
parameter选择正确的注册操作。
在你的情况下(协会),它可能是
[Registry]
section,如果您让安装人员进行注册或[Run]
section,如果您将注册委托给某个应用程序。 [Registry]
部分条目的示例:
[Registry]
Root: HKCR; Subkey: "program1\DefaultIcon"; ValueType: string; ValueName: ""; \
ValueData: "{app}\program1.EXE,0"; Tasks: associate\app1
Root: HKCR; Subkey: "program1\shell\open\command"; ValueType: string; ValueName: ""; \
ValueData: """{app}\program1.exe"" ""%1"""; Tasks: associate\app1
Root: HKCR; Subkey: "program1\DefaultIcon"; ValueType: string; ValueName: ""; \
ValueData: "{app}\program2.EXE,0"; Tasks: associate\app2
Root: HKCR; Subkey: "program1\shell\open\command"; ValueType: string; ValueName: ""; \
ValueData: """{app}\program2.exe"" ""%1"""; Tasks: associate\app2
Root: HKCR; Subkey: "program1\DefaultIcon"; ValueType: string; ValueName: ""; \
ValueData: "{app}\program3.EXE,0"; Tasks: associate\app3
Root: HKCR; Subkey: "program1\shell\open\command"; ValueType: string; ValueName: ""; \
ValueData: """{app}\program3.exe"" ""%1"""; Tasks: associate\app3
(我不确定你的program1
密钥,它不应该是扩展名或文件类型吗?)
为避免重复几乎相同的Registry
条目,您可以使用scripted constant:
[Registry]
Root: HKCR; Subkey: "program1\DefaultIcon"; ValueType: string; ValueName: ""; \
ValueData: "{app}\{code:AssociateExecutable},0"; Tasks: associate
Root: HKCR; Subkey: "program1\shell\open\command"; ValueType: string; ValueName: ""; \
ValueData: """{app}\{code:AssociateExecutable}"" ""%1"""; Tasks: associate
[Code]
function AssociateExecutable(Param: string): string;
begin
if IsTaskSelected('associate\app1') then Result := 'program1.exe'
else
if IsTaskSelected('associate\app2') then Result := 'program2.exe'
else
if IsTaskSelected('associate\app3') then Result := 'program3.exe'
else
begin
Log('No application selected, this should not happen');
Result := '';
end;
end;