我需要你的帮助。
我想知道Inno是否有可能为2种产品设置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的下拉菜单中,我们看到“灰色”复选框)。
有没有办法在安装“程序”时完全隐藏“ C.exe”和“ D.exe”,在安装“ SETUP”时完全隐藏“ 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;
请注意,一旦您从
ComponentsList
中删除了这些项目,便无法将它们重新添加回去,因为每个项目都持有一个TItemState
对象实例,该实例在删除时释放,并且无法从脚本中创建或定义此类对象。