Inno设置任务揭开神秘面纱

目录

介绍

使用代码

兴趣点


介绍

很长一段时间以来,我都没有意识到Inno Setup [Tasks]的用处,我使用自定义页面来处理更复杂的设置场景。

最近,我决定试一试[Tasks],发现它可以使一些安装场景变得简单得多。

使用代码

在下面的代码中,显示了一些无害的虚拟应用程序的最小示例。该代码应适用于Inno Setup v5或更高版本。此外,虚拟应用程序的代码在这里并不重要,但对于那些感兴趣的人,我已经包含了VS2022代码。

当用户选择客户端选项时,不会显示任务页。当用户选择服务器选项时,将显示任务页面,选中“Postgres”选项后,将在服务器应用之前安装”Postgres

;
; Test [Tasks] for Inno Setup
; Simulates a simple Client or Server installation using dummy .exe files.
;
#define MyAppName "Tasks_Test"
#define MyAppVersion "1.0"
#define MyAppPublisher "RickZeeland"

[Setup]
; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{CEB74C97-297E-49DA-AD56-CB816A92E20B}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
DefaultDirName={pf64}\{#MyAppName}
DefaultGroupName={#MyAppName}
; Uncomment the following line to run in non administrative install mode (install for current user only.)
;PrivilegesRequired=lowest
OutputBaseFilename=Tasks_Test
Compression=lzma
SolidCompression=yes
WizardStyle=modern
ArchitecturesAllowed=x64
; "ArchitecturesInstallIn64BitMode=x64" requests that the install be
; done in "64-bit mode" on x64, meaning it should use the native
; 64-bit Program Files directory and the 64-bit view of the registry.
ArchitecturesInstallIn64BitMode=x64
; Do not ask for PC restart.
RestartIfNeededByRun=no

[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"

[Types]
; Prevent showing the Types ComboBox
Name: "custom"; Description: "Custom installation"; Flags: iscustom

[Components]
Name: "client"; Description: "Client"; Flags: exclusive
Name: "server"; Description: "Server"; Flags: exclusive

[Tasks]
; The postgres Task page is only shown when server is selected
Name: "postgres"; Description: "PostgreSQL installation";  Components: server

[Files]
Source: "ClientDummy.exe"; DestDir: "{app}"; Components: client; Flags: ignoreversion
Source: "ServerDummy.exe"; DestDir: "{app}"; Components: server; Flags: ignoreversion
; Postgres dummy is only installed when server is selected and task postgres is checked
Source: "PostgresDummy.exe"; DestDir: "{app}"; Tasks: postgres; Flags: ignoreversion

[Icons]
Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"

[Run]
Filename: "{app}\PostgresDummy.exe"; Description: "{cm:LaunchProgram, Postgres dummy app}"; Tasks: postgres;    Flags: waituntilterminated postinstall skipifsilent
Filename: "{app}\ClientDummy.exe"; Description: "{cm:LaunchProgram, Client dummy app}";     Components: client; Flags: nowait postinstall skipifsilent
Filename: "{app}\ServerDummy.exe"; Description: "{cm:LaunchProgram, Server dummy app}";     Components: server; Flags: nowait postinstall skipifsilent

兴趣点

要在Inno Setup [Code]部分中访问Tasks,可以使用以下命令:

IsTaskSelected('postgres')

Windows“开始菜单或设置中,Tasks_Test可以卸载。

https://www.codeproject.com/Tips/5370107/Inno-Setup-Tasks-Demystified

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值