简体   繁体   English

InnoSetup:根据安装程序中的值在Common / User Desktop中生成图标

[英]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 Section: 图标部分:

[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"

Code: 码:

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.

相关问题 InnoSetup for Mac等安装程序 - Installer like InnoSetup for Mac wix,InnoSetup,nsis的安装程序开销 - Installer overhead of wix, InnoSetup, nsis InnoSetup - 桌面上的快捷方式图标已损坏 - InnoSetup - Shortcut Icon on desktop corrupted admin level nsis安装程序需要为非特权用户创建图标 - admin level nsis installer needs to create icons for unprivileged user 永久自定义文件夹图标与InnoSetup在任何计算机中 - Permanent customized folder icons with InnoSetup in any computer InnoSetup - 检查是否安装了visual studio 2010 crt redist,如果没有,则运行安装程序 - InnoSetup - Check if visual studio 2010 crt redist is installed, if not then run installer 即时从* nix Web服务器生成基于Windows的自定义EXE安装程序(OpenVPN客户端自定义安装程序) - Generate custom Windows-based EXE installer from *nix webserver on the fly (OpenVPN client custom installer) 在InnoSetup的语言文件中获取[Messages]值 - Get [Messages] values in InnoSetup's language file 基于用户的Installer Project中以前版本的删除 - User-based removal of previous version in Installer Project 如何基于框架内的组件为作曲家安装程序设置不同的路径 - How to set a different path for composer installer based on components inside a framework
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM