[英]InnoSetup: Generate Icons in Common/User Desktop based on values inside Installer
We provide a custom Wizard page in our InnoSetup configuration that gives us an InstallForAllUsers
variable. 我们在InnoSetup配置中提供了一个自定义向导页面,该页面为我们提供了一个InstallForAllUsers
变量。 Based on the value of this variable, we want to place our icons in the appropriate places Common Desktop
/ Common Startup
for All Users, and User Desktop
/ User Startup
for Current User. 基于此变量的值,我们希望将图标放置在所有用户的“ Common Desktop
/ Common Startup
”和“当前用户的User Desktop
/ User Startup
的适当位置。
Our Icons section looks like this: 我们的图标部分如下所示:
[Icons]
Name: "{group}\MyApp"; Filename: "{app}\MyApp.exe"; IconFilename: "{app}\MyApp.exe"
Name: "{group}\{cm:UninstallProgram,MyApp}"; Filename: "{uninstallexe}"; IconFilename: E:\Continuous Integration\InnoSetup Files\icon.ico
Name: "{commondesktop}\MyApp"; Filename: "{app}\MyApp.exe"; IconFilename: "{app}\MyApp.exe"
Name: "{commonstartup}\MyApp"; Filename: "{app}\MyApp.exe"; IconFilename: "{app}\MyApp.exe"
How can I leverage my InstallForAllUsers
variable to replace these constants when necessary? 在必要时如何利用我的InstallForAllUsers
变量替换这些常量?
[Icons]
Name: "{group}\MyApp"; Filename: "{app}\MyApp.exe"; IconFilename: "{app}\MyApp.exe"
Name: "{group}\{cm:UninstallProgram,MyApp}"; Filename: "{uninstallexe}"; IconFilename: E:\Continuous Integration\InnoSetup Files\icon.ico
Name: "{code:GetDesktopFolder}\MyApp"; Filename: "{app}\MyApp.exe"; IconFilename: "{app}\MyApp.exe"
Name: "{code:GetStartupFolder}\MyApp"; Filename: "{app}\MyApp.exe"; IconFilename: "{app}\MyApp.exe"
function GetDesktopFolder(Param: String): String;
begin
if (InstallAllUsers) then
Result := ExpandConstant('{commondesktop}')
else
Result := ExpandConstant('{userdesktop}');
end;
function GetStartupFolder(Param: String): String;
begin
if (InstallAllUsers) then
Result := ExpandConstant('{commonstartup}')
else
Result := ExpandConstant('{userstartup}');
end;
You can use a Check:
function that returns the "all users" variable to control whether the icon is created or not: 您可以使用Check:
函数来返回“所有用户”变量,以控制是否创建图标:
[Icons]
Name: "{commondesktop}\MyApp"; Filename: "{app}\MyApp.exe"; IconFilename: "{app}\MyApp.exe"; Check: Not CheckPerUserInstall;
Name: "{userdesktop}\MyApp"; Filename: "{app}\MyApp.exe"; IconFilename: "{app}\MyApp.exe"; Check: CheckPerUserInstall;
Name: "{commonstartup}\MyApp"; Filename: "{app}\MyApp.exe"; IconFilename: "{app}\MyApp.exe"; Check: Not CheckPerUserInstall;
Name: "{userstartup}\MyApp"; Filename: "{app}\MyApp.exe"; IconFilename: "{app}\MyApp.exe"; Check: CheckPerUserInstall;
[Code]
function CheckPerUserInstall(): Boolean;
begin
Result := InstallForAllUsers;
end;
Note that the {user*}
constants may very well be for a different user to the expected one if run from a limited user account. 请注意,如果使用受限用户帐户运行, {user*}
常量可能非常适合与预期用户不同的用户。 This is the primary reason why "per user" installs aren't that common anymore. 这是“每用户”安装不再常见的主要原因。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.