[英]How to allow to only install specific components in InnoSetup?
所以问题是:我在这里问了一个问题: 如何只允许安装到特定的文件夹?
如何修改它,例如,我有3个文件要安装,其中2个是可选的,如果存在某个文件/文件夹,应该只能安装。 如果条件不满足,我想在列表中选择它们的灰色选项?
先感谢您。 索尔特
我会尝试做以下事情。 它将访问组件列表项,通过索引禁用和取消选中它们,从[Components]
部分的顺序开始从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;
上述解决方案至少有一个缺点。 该指数可能从原来的顺序被打乱[Components]
节当您将ComponentsList.Sorted
为True。 如果你不这样做
使用它,它可能足以使用上面的代码,如果是的话,那就更复杂了。
没有简单的方法来获取组件名称(它在内部存储为每个项目的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;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.