Search code examples
inno-setuppascalscript

Checking if only one specific component is selected in Inno Setup


I have a requirement to skip a page when only a particular component is selected in the component selection page. Please look at the below image

Component Selection Page

[Components]
Name: DBS\TRACE; Types: DBS TBLWOS; Description: DBS Tracing Bodylife Database;

The requirement is to skip a page when the option "DBS Tracing Bodylife Database" (highlighted in the image) alone is selected and clicked on Next button. If I select only that option, I am successfully able to skip the page using below code.

if PageID = PageToBeSkipped.ID then begin
    Result := not (IsComponentSelected('not DBS\TRACE'));
end;

But If I select any other additional component along with the "DBS Tracing Bodylife Database" from this page which is nearly 20, the page should not be skipped. The above code skips the page if any additional component is selected too.

How can I handle this?

Thanks in advance!


Solution

  • To test if any component, except one specific, is selected, you can use WizardSelectedComponents function (which returns a comma-separated list of selected components).

    function ShouldSkipPage(PageID: Integer): Boolean;
    begin
      Result := False;
    
      if PageID = PageToBeSkipped.ID then
      begin
        Result := (CompareText(WizardSelectedComponents(False), 'DBS,DBS\TRACE') = 0);
      end;
    end;
    

    Note that the WizardSelectedComponents returns even "partially" selected components groups.