inno-setuppascalscriptfileopendialog

How to select multiple files in open dialog box in Inno Setup?


These are the two methods in Inno Setup to show file selection dialog,

Wizard Page Method:

[Code]
Var
  PageFileDialog: TInputFileWizardPage;

procedure InitializeWizard;
begin
  PageFileDialog:= CreateInputFilePage(
    wpWelcome, 
    'Title 1', 
    'Title 2', 
    'Title 3'); 
 
  PageFileDialog:= PageFileDialog.Edits[PageFileDialog.Add('', 'Text file (*.txt)|*.txt', '.txt')];
end;

Direct Open Dialog,

[Code]
procedure InitializeWizard;
var
    FileName: string;
begin
    FileName := '';
    if GetOpenFileName('', FileName, '', 
    'Text Documents (*.txt)|*.txt|All Files|*.*', 'txt') then
    begin
       { Filename contains the selected filename }
    end;
end;

But these does no allow to select multiple files in the open dialog, It only selects one file. How to select multiple files?

The method in question Inno Setup with three destination folders does not work here. It should be one textbox and browse button that can select multiple files.


Solution

  • I tested with Inno Setup 6.0.5(u). Other versions may be different.

    Take a look at the GetOpenFileNameMulti function: From the documentation:

    Description:
    Displays a dialog box that enables the user to select one or more existing file(s). Returns True if the user selected a file, False otherwise. The name of the selected file(s) is returned in the FileNameList list.

    Remarks:
    An example Filter: 'Text files (.txt)|.txt|All files (.)|.'

    Example:

    var
      FileNameList: TStrings;
    begin
      { Create the list }
      FileNameList := TStringList.Create;
      try
        if GetOpenFileNameMulti('', FileNameList, '',
           'Text Documents (*.txt)|*.txt|All Files|*.*', 'txt') then
        begin
          { Successful; user clicked OK }
          { FileNameList contains the selected filename(s) }
        end;
      finally
        FileNameList.Free;
      end;
    end;