简体   繁体   English

InnoSetup,如果选择任何任务,则阻止安装

[英]InnoSetup, prevent installation if any task is selected

My inno script has two tasks: 我的inno脚本有两个任务:

[Tasks]
Name: client; Description: Install FTP client
Name: server; Description: Install FTP server

I would like to deny the installation in a non-intrusive way if any task is selected, for non.intrusive I mean for example enabling/disabling the "next" button when one of both tasks are checked, no advertising messagbe-box. 如果要选择任何任务,我想以一种非侵入式的方式拒绝安装,对于非侵入式,我的意思是例如在选中两个任务之一时启用/禁用“下一步”按钮,没有广告消息框。

I'm not sure if innosetup has a parameter or a "check" function to do this in a simple way 我不确定innosetup是否具有参数或“检查”功能以简单的方式执行此操作

How I could do it? 我该怎么办?

There is no way to do what you want natively in Inno Setup. 在Inno Setup中无法进行您本机想要的操作。 You will need to do it from code by yourself. 您需要自己通过代码来完成。

You can cheat here a bit by using the WizardSelectedTasks function. 您可以使用WizardSelectedTasks函数在此处作弊。 This function returns a comma separated list of selected task names (or descriptions), and so it returns an empty string when no task is selected. 此函数返回以逗号分隔的所选任务名称(或描述)列表,因此当未选择任何任务时,它将返回空字符串。 The rest is about binding task list OnClickCheck event, and updating the next button enable state and writing a piece of code to initialize the next button state: 剩下的就是绑定任务列表的OnClickCheck事件,并更新下一个按钮的启用状态,并编写一段代码来初始化下一个按钮的状态:

[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName={pf}\My Program

[Tasks]
Name: client; Description: Install FTP client
Name: server; Description: Install FTP server

[Code]
// helper function
function IsAnyTaskSelected: Boolean;
begin
  Result := WizardSelectedTasks(False) <> '';
end;

// event handler for setting the next button initial state when
// entering the tasks page
procedure CurPageChanged(CurPageID: Integer);
begin
  if CurPageID = wpSelectTasks then
    WizardForm.NextButton.Enabled := IsAnyTaskSelected;
end;

// method of the task list check click event
procedure TasksListClickCheck(Sender: TObject);
begin
  WizardForm.NextButton.Enabled := IsAnyTaskSelected;
end;

procedure InitializeWizard;
begin
  WizardForm.TasksList.OnClickCheck := @TasksListClickCheck;
end;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM