So the question is this: I asked a question back here: How to allow installation only to a specific folder?
How can I modify it a bit, so for example, I have 3 files
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;