从一个安装切换到另一个安装时,Inno设置隐藏安装项目

Mel*_*ena 2 inno-setup

我应该需要你的帮助.

我想知道Inno是否有可能为2个产品设置2个不同的安装掩模(通过从Dropdown中选择).

我们将调用2个不同的安装"SETUP"和"PROGRAM".

安装"SETUP"时,我们应该可以选中/取消选中以下框:
A.exe,B.exe,C.exe和D.exe将被安装(不应该看到其他复选框).

当安装"PROGRAM"我们应该有检查/为A.exe时,B.EXE(常见的"SETUP"),F.exe和G.exe取消选中复选框(没有其他的盒子应该看到的)的可能性.

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

有没有办法在安装"PROGRAM"时完全隐藏"C.exe"和"D.exe"并在安装"SETUP"时完全隐藏"F.exe"和"G.exe"?

在此先感谢您的帮助.

Meleena.

TLa*_*ama 5

要在运行时隐藏组件,我能想到的唯一方法(在当前版本中)是从组件列表中删除项目.此时,您只能通过其描述可靠地识别组件,因此此代码中的想法是制作组件描述列表,迭代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;
Run Code Online (Sandbox Code Playgroud)

请注意,一旦您从中删除了项目ComponentsList,就无法将它们添加回来,因为每个项目都包含一个TItemState在删除时释放的对象实例,并且无法从脚本创建或定义此类对象.