Inno setup Inno setup在从一个安装切换到另一个安装时隐藏安装项目

Inno setup Inno setup在从一个安装切换到另一个安装时隐藏安装项目,inno-setup,Inno Setup,我需要你的帮助 我想知道Inno是否有可能为2种产品设置2个不同的安装掩码(从下拉列表中选择) 我们将这两种不同的安装称为“设置”和“程序” 安装“设置”时,我们应该可以选中/取消选中以下复选框: 将要安装的A.exe、B.exe、C.exe和D.exe(不应看到其他复选框) 在安装“程序”时,我们应该可以选中/取消选中 A.exe、B.exe(通用于“设置”)、F.exe和G.exe(不应看到其他框) 我试图在[Components]部分添加“Flags:fixed”,但无法隐藏链接到其他安装

我需要你的帮助

我想知道Inno是否有可能为2种产品设置2个不同的安装掩码(从下拉列表中选择)

我们将这两种不同的安装称为“设置”和“程序”

安装“设置”时,我们应该可以选中/取消选中以下复选框:
将要安装的A.exe、B.exe、C.exe和D.exe(不应看到其他复选框)

在安装“程序”时,我们应该可以选中/取消选中 A.exe、B.exe(通用于“设置”)、F.exe和G.exe(不应看到其他框)

我试图在[Components]部分添加“Flags:fixed”,但无法隐藏链接到其他安装的复选框(在选择安装程序或程序时,从下拉菜单中我们会看到“灰色”复选框)

安装“程序”时是否有办法完全隐藏“C.exe”和“D.exe”,安装“安装程序”时是否有办法完全隐藏“F.exe”和“G.exe”

提前感谢你的帮助


Meleena.

要在运行时隐藏组件,我能想到的唯一方法(在当前版本中)是从组件列表中删除项目。此时,您只能通过其描述可靠地识别组件,因此本代码中的想法是制作组件描述列表,迭代
ComponentsList
,并删除所有与其描述匹配的内容:

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

[Components]
Name: "ProgramA"; Description: "{cm:CompDescrProgramA}";
Name: "ProgramB"; Description: "{cm:CompDescrProgramB}";
Name: "ProgramC"; Description: "{cm:CompDescrProgramC}";
Name: "ProgramD"; Description: "{cm:CompDescrProgramD}";

[CustomMessages]
; it's much better for maintenance to store component descriptions
; into the [CustomMessages] section
CompDescrProgramA=Program A
CompDescrProgramB=Program B
CompDescrProgramC=Program C
CompDescrProgramD=Program D

[Code]
function ShouldHideCD: Boolean;
begin
  // here return True, if you want to hide those components, False
  // otherwise; it is the function which identifies the setup type
  Result := True;
end;

procedure DeleteComponents(List: TStrings);
var
  I: Integer;
begin
  // iterate component list from bottom to top
  for I := WizardForm.ComponentsList.Items.Count - 1 downto 0 do
  begin
    // if the currently iterated component is found in the passed
    // string list, delete the component
    if List.IndexOf(WizardForm.ComponentsList.Items[I]) <> -1 then
      WizardForm.ComponentsList.Items.Delete(I);
  end;
end;

procedure InitializeWizard;
var
  List: TStringList;
begin
  // if components should be deleted, then...
  if ShouldHideCD then
  begin
    // create a list of component descriptions
    List := TStringList.Create;
    try
      // add component descriptions
      List.Add(ExpandConstant('{cm:CompDescrProgramC}'));
      List.Add(ExpandConstant('{cm:CompDescrProgramD}'));
      // call the procedure to delete components
      DeleteComponents(List);
    finally
      // and free the list
      List.Free;
    end;
  end;
end;
[设置]
AppName=我的程序
AppVersion=1.5
DefaultDirName={pf}\My程序
[组成部分]
名称:“方案A”;说明:“{cm:CompDescrProgramA}”;
名称:“程序B”;说明:“{cm:CompDescrProgramB}”;
名称:“ProgramC”;说明:“{cm:CompDescrProgramC}”;
名称:“已编程”;说明:“{cm:CompDescrProgramD}”;
[定制信息]
; 对于维护来说,存储组件描述要好得多
; 进入[CustomMessages]部分
CompDescrProgramA=程序A
CompDescrProgramB=程序B
CompDescrProgramC=程序C
CompDescrProgramD=程序D
[守则]
函数应为:布尔型;
开始
//这里返回True,如果要隐藏这些组件,则返回False
//否则;它是识别设置类型的功能
结果:=真;
结束;
程序删除组件(列表:T管柱);
变量
I:整数;
开始
//从下到上迭代组件列表
对于I:=WizardForm.ComponentsList.Items.Count-1到0
开始
//如果在传递的
//字符串列表,删除该组件
如果List.IndexOf(WizardForm.ComponentsList.Items[I])-1,则
WizardForm.ComponentsList.Items.Delete(I);
结束;
结束;
程序初始化;
变量
列表:TStringList;
开始
//如果应该删除组件,则。。。
如果应该考虑的话
开始
//创建组件描述的列表
列表:=TStringList.Create;
尝试
//添加组件描述
Add(ExpandConstant({cm:CompDescrProgramC}');
Add(ExpandConstant({cm:CompDescrProgramD}');
//调用该过程以删除组件
删除组件(列表);
最后
//然后释放列表
列表。免费;
结束;
结束;
结束;

请注意,一旦从
组件列表
中删除了这些项,就无法再添加它们,因为每个项都包含一个对象实例,该实例在删除时发布,并且无法从脚本中创建或定义此类对象。

我能想到的唯一方法是从组件列表中删除这些项。但是,此时您需要从下到上迭代删除与组件名称匹配的组件。您好,谢谢您的回答。请耐心等待,因为我不是程序员。您可以向我展示迭代的正确编码吗?Meleena,我刚刚发布了一个(注释)如何在运行时删除组件的原则,因为你没有说你是通过什么来确定安装类型的。如果您在实际情况中遇到一些问题,请让我解释“安装”和“程序”的含义。