通过Inno Setup中的任务启动自定义代码 [英] Launch custom code via tasks in Inno Setup
问题描述
如果用户在安装过程中选中了相应的复选框,我想执行一些代码.通过阅读帮助文件,看来使用该任务的唯一方法是将其与Files
/Icons
/etc中的条目相关联.部分.我真的很想将它与Code
部分中的过程相关联.可以这样做吗?如果可以,怎么办?
I want to execute some code if a user checks a corresponding checkbox during the install. From reading the help file, it looks like the only way to use the task is to associate it with an entry in the Files
/Icons
/etc. section. I'd really like to associate it with a procedure in the Code
section. Can this be done and if so, how?
推荐答案
您可以通过添加一个具有复选框的自定义向导页面来执行此操作,并在用户单击下一步"时为所有选中的复选框执行代码.在该页面上:
You do that by adding a custom wizard page that has check boxes, and execute the code for all selected check boxes when the user clicks "Next" on that page:
[Code]
var
ActionPage: TInputOptionWizardPage;
procedure InitializeWizard;
begin
ActionPage := CreateInputOptionPage(wpReady,
'Optional Actions Test', 'Which actions should be performed?',
'Please select all optional actions you want to be performed, then click Next.',
False, False);
ActionPage.Add('Action 1');
ActionPage.Add('Action 2');
ActionPage.Add('Action 3');
ActionPage.Values[0] := True;
ActionPage.Values[1] := False;
ActionPage.Values[2] := False;
end;
function NextButtonClick(CurPageID: Integer): Boolean;
begin
Result := True;
if CurPageID = ActionPage.ID then begin
if ActionPage.Values[0] then
MsgBox('Action 1', mbInformation, MB_OK);
if ActionPage.Values[1] then
MsgBox('Action 2', mbInformation, MB_OK);
if ActionPage.Values[2] then
MsgBox('Action 3', mbInformation, MB_OK);
end;
end;
这些复选框可以是标准控件,也可以是列表框中的项目,有关详细信息,请参见Pascal Scripting上的Inno Setup文档.
The check boxes can either be standard controls or items in a list box, see the Inno Setup documentation on Pascal Scripting for details.
如果要根据是否选择了某个组件或任务来执行代码,请改用WizardIsComponentSelected()
和WizardIsTaskSelected()
函数.
If you want your code to be executed depending on whether a certain component or task has been selected, then use the WizardIsComponentSelected()
and WizardIsTaskSelected()
functions instead.
这篇关于通过Inno Setup中的任务启动自定义代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!