gpt4 book ai didi

inno-setup - 从一种安装切换到另一种安装时,Inno setup 会隐藏安装项目

转载 作者:行者123 更新时间:2023-12-04 01:12:41 25 4
gpt4 key购买 nike

我需要你的帮助。

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

我们将这 2 个不同的安装称为“SETUP”和“PROGRAM”。

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

安装“PROGRAM”时,我们应该可以选中/取消选中以下复选框A.exe、B.exe(与“SETUP”相同)、F.exe 和 G.exe(不应看到其他框)。

我尝试在 [组件] 部分添加“标志:已修复”,但无法隐藏链接到其他安装的复选框(在选择安装“设置”或“程序”时,从下拉菜单中我们看到“灰色”复选框)框)。

有没有办法在安装“PROGRAM”时完全隐藏“C.exe”和“D.exe”以及在安装“SETUP”时完全隐藏“F.exe”和“G.exe”?

预先感谢您的帮助。

梅琳娜。

最佳答案

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

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

关于inno-setup - 从一种安装切换到另一种安装时,Inno setup 会隐藏安装项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25158667/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com