InnoSetup,如果选择任何任务,则阻止安装 [英] InnoSetup, prevent installation if any task is selected

查看:186
本文介绍了InnoSetup,如果选择任何任务,则阻止安装的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的inno脚本有两个任务:

My inno script has two tasks:

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

我不确定innosetup是否具有参数或检查"功能来以简单的方式做到这一点

I'm not sure if innosetup has a parameter or a "check" function to do this in a simple way

我该怎么做?

推荐答案

在Inno Setup中无法自然地完成您想做的事情.您将需要自己通过代码来做到这一点.

There is no way to do what you want natively in Inno Setup. You will need to do it from code by yourself.

您可以使用 WizardSelectedTasks 作弊功能.此函数返回用逗号分隔的所选任务名称(或描述)列表,因此,当未选择任何任务时,它将返回一个空字符串.剩下的就是绑定任务列表OnClickCheck事件,并更新下一个按钮的启用状态并编写一段代码来初始化下一个按钮的状态:

You can cheat here a bit by using the WizardSelectedTasks function. 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:

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

这篇关于InnoSetup,如果选择任何任务,则阻止安装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆