How to check and fix a component in a InnoSetup pr

2019-05-23 01:50发布

问题:

I'm developing a InnoSetup project and I'm wondering how to always install a component (let's say 'Acrobat Reader') but don't allow to uncheck that item in the list of components.
I don't want the user uncheck it.

回答1:

Generally, a component is selected when the selected installation type is listed in the Types parameter of its entry. So if you list all the available installation types there, it will be selected always.

To disable the component so that users cannot modify its state, you need to include the fixed flag for the entry.

So to make a disabled, always selected component with default installation types (which are used when you don't specify your own installation types in the [Types] section), you would write entry like this:

[Components]
Name: "main"; Description: "Main Files"; Types: full compact custom; Flags: fixed

In your comment you've asked how to disable a task entry. As far as I know, there is no direct way to do this and the only way I could come up with is doing this in code from the CurPageChanged event:

[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName={pf}\My Program

[Tasks]
Name: something; Description: "Install something"

[Code]
procedure CurPageChanged(CurPageID: Integer);
begin
  // the ItemEnabled property uses a 0 based index for item access, so the following
  // code you can read as, if we have entered the tasks selection page, disable the
  // first tasks list item
  if CurPageID = wpSelectTasks then
    WizardForm.TasksList.ItemEnabled[0] := False;
end;


标签: inno-setup