仅在选择了特定组件时才会检查Inno设置任务

时间:2015-02-27 23:51:16

标签: inno-setup

可以通过简单列出Components: a b c等将任务设置为依赖于所选组件进行显示,并且可以通过指定Flags: unchecked将其设置为默认情况下不进行检查。但是,如果只选择了一个特定组件并且对所有其他组件保持未选中状态,则似乎没有办法使用Code运行条件检查以检查任务。

Name: "SystemInfo"; Description: "Audit System Information"; GroupDescription: "Additional Setup Options"; Flags: unchecked; Components: Client Standalone Server

如果选择了Client,Standalone或Server组件,我希望将SystemInfo任务显示为可选项,但如果选择了Server组件,我希望默认情况下检查此选项,而不是取消选中。基本上,有没有办法在代码中执行Check: IsComponentServerSelected并删除Flag: unchecked如果为真?也许我忽略了另一种方法吗?

1 个答案:

答案 0 :(得分:1)

我对这个解决方案并不完全满意,但至少看起来似乎有效。可以通过创建两个类似的[Task]条目并显示依赖于所选组件的已检查或未选中的条目来实现此目的,如下所示:

Name: "SystemInfo"; Description: "Audit System Information"; GroupDescription: "Additional Setup Options"; Flags: unchecked; Components: Client
Name: "SystemInfoServer"; Description: "Audit System Information"; GroupDescription: "Additional Setup Options"; Components: Server Standalone

然后在[Code]引用这两个任务,而不仅仅是那个:

      if IsTaskSelected('SystemInfo') or IsTaskSelected('SystemInfoServer') then
    begin;
      AuditSystemInfo;
    end;

我仍然有兴趣听听是否有更好的解决方案,只允许存在一个任务,并根据所选组件动态更改标志状态。请注意,我确实尝试使用Flag: {code: GetAuditFlag},但这不起作用,我假设因为它太早被调用,即在安装程序初始化之前。

相关问题