我希望在我的 InnoSetup 中允许客户安装两个程序之一或同时安装两个程序。
我制作了额外的选择面板,用户可以在其中检查他想要安装的内容,但我有以下问题
- 如何更改硬编码的 AppName?
如何动态判断程序安装位置?
例如默认安装目录是 >
Program Files\Program 1
如何将其更改为Program Files\Program 2
如何更改 UninstallDisplayIcon?
当前
UninstallDisplayIcon={app}\program1.exe
如何更改它取决于选择的设置:
UninstallDisplayIcon={app}\program2.exe
当前配置(来自评论):
[Run]
Filename: {app}\{#MyAppExeName};
Description: {cm:LaunchProgram,{#MyAppName}};
Flags: nowait postinstall skipifsilent
其中 MyAppExeName 当前是在文件开头定义的常量。
我的问题是如何做这样的事情:
[Run]
Filename: {app}\MYFUNCTIONFROMCODESECTION_THAT_WILL_RETURN_NAME;
Description: {cm:LaunchProgram,{#MyAppName}};
Flags: nowait postinstall skipifsilent
最佳答案
如何在运行时更改 AppName 指令值?
无法更改 AppName
运行时的指令值,因为它是在安装程序的初始化时评估的。
如何有条件地指定安装文件目的地?
为此,您可以使用 {code:...}
脚本常量。例如:
[Files]
Source: "MyApp.exe"; DestDir: "{code:GetMyAppDestDir}"
[Code]
function GetMyAppDestDir(Value: string): string;
begin
Result := '<Here return the path where the file should be installed...>';
end;
如何在运行时更改 UninstallDisplayIcon 指令值?
为此,您还可以使用 {code:...}
脚本常量。例如:
[Setup]
UninstallDisplayIcon={code:GetUninstallDisplayIcon}
[Code]
function GetUninstallDisplayIcon(Value: string): string;
begin
Result := '<Here return the path of the icon to be used for uninstaller...>';
end;
关于installation - 在安装文件中创建自定义可执行名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23084473/