Inno Setup 使用应用程序路径的一部分作为图标路径

Inno Setup Use a part of an application path for an icon path

我需要在图标名称中插入安装目录的最后一部分。

为此,我尝试使用 ExtractFileName({app}),并将其结果插入图标的 Name 参数中。

[Icons]
Name: '{group}\ApplicationName\' + ExtractFileName({app}) + '\filename.txt' 

它可以编译,但在运行时出现 123 错误,告诉我

c:\Windows\system32\'c: could not be created.

我只需要在开始菜单中插入安装路径的基本名称作为新级别。

您正在寻找 scripted constant

[Icons]
Name: "{group}\ApplicationName\{code:GetAppName}\filename.txt"

[Code]

function GetAppName(Param: string): string;
begin
  Result := ExtractFileName(ExpandConstant('{app}'));
end;