所以,问题是这样的:我问一个问题回到这里: 如何让安装只对特定的文件夹?
我怎样才能稍作修改,因此,例如,我有3个文件来安装,其中2是可选的,只应适用于安装,如果某个文件/文件夹是否存在。 我要灰的选项列表中选择它们,如果条件不具备?
先感谢您。 索尔特
所以,问题是这样的:我问一个问题回到这里: 如何让安装只对特定的文件夹?
我怎样才能稍作修改,因此,例如,我有3个文件来安装,其中2是可选的,只应适用于安装,如果某个文件/文件夹是否存在。 我要灰的选项列表中选择它们,如果条件不具备?
先感谢您。 索尔特
I would try to do the following. It will access the component list items, disable and uncheck them by their index, what is the number starting from 0 taken from the order of the [Components]
section. The items without fixed
flag (like in this case) are by default enabled, thus you need to check if the condition has not been met instead. You may check also the commented version
of this post:
[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;
The solution above has at least one weakness. The indexes might be shuffled from the original order from the [Components]
section when you set the ComponentsList.Sorted
to True. If you don't
use it, it might be enough to use the above code, if yes, then it's more complicated.
There is no simple way to get the component name (it is stored internally as TSetupComponentEntry
object in the ItemObject
of each item), only the description, so here is another way to do the same with the difference that the item indexes are being searched by their descriptions specified.
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;