加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

conditional – 如何只允许在InnoSetup中安装特定组件?

发布时间:2020-12-15 10:11:58 所属栏目:大数据 来源:网络整理
导读:所以问题是: 我在这里问了一个问题: How to allow installation only to a specific folder? 如何修改它,例如,我有3个文件要安装,其中2个是可选的,只有安装时才可用,如果存在某个文件/文件夹.如果条件不满足,我想在列表中选择它们的灰色选项? 先谢谢你.
所以问题是:
我在这里问了一个问题: How to allow installation only to a specific folder?

如何修改它,例如,我有3个文件要安装,其中2个是可选的,只有安装时才可用,如果存在某个文件/文件夹.如果条件不满足,我想在列表中选择它们的灰色选项?

先谢谢你.
索尔特

解决方法

我会尝试做以下事情.它将访问组件列表项,通过索引禁用和取消选中它们,从0000部分的顺序开始从0开始的数字是多少.默认情况下,启用了没有 fixed标志的项目(如本例中所示),因此您需要检查是否未满足条件.您也可以查看这篇文章的 commented version
[Components]
Name: Component1; Description: Component 1
Name: Component2; Description: Component 2
Name: Component3; Description: Component 3

[code]
procedure CurPageChanged(CurPageID: Integer);
begin
  if CurPageID = wpSelectComponents then
    if not SomeCondition then
    begin
      WizardForm.ComponentsList.Checked[1] := False;
      WizardForm.ComponentsList.ItemEnabled[1] := False;
      WizardForm.ComponentsList.Checked[2] := False;
      WizardForm.ComponentsList.ItemEnabled[2] := False;
    end;
end;

上述解决方案至少有一个缺点.将ComponentsList.Sorted设置为True时,索引可能会从[Components]部分的原始顺序中拖曳.如果您不使用它,使用上面的代码就足够了,如果是的话,那就更复杂了.

没有简单的方法来获取组件名称(它在内部存储为每个项目的ItemObject中的TSetupComponentEntry对象),只有描述,所以这里是另一种方法来做同样的事情,区别是项目索引被搜索他们的描述指定.

procedure CurPageChanged(CurPageID: Integer);
var
  Index: Integer;
begin
  if CurPageID = wpSelectComponents then
    if not SomeCondition then
    begin
      Index := WizardForm.ComponentsList.Items.IndexOf('Component 2');
      if Index <> -1 then
      begin
        WizardForm.ComponentsList.Checked[Index] := False;
        WizardForm.ComponentsList.ItemEnabled[Index] := False;
      end;
      Index := WizardForm.ComponentsList.Items.IndexOf('Component 3');
      if Index <> -1 then
      begin
        WizardForm.ComponentsList.Checked[Index] := False;
        WizardForm.ComponentsList.ItemEnabled[Index] := False;
      end;
    end;
end;

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读