如何在Inno Setup的打开对话框中选择多个文件?

问题描述

这是Inno Setup中显示文件选择对话框的两种方法,

向导页面方法:

[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;

直接打开对话框,

[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;

但是这些不允许在打开的对话框中选择多个文件,它只能选择一个文件。如何选择多个文件?

有问题的方法Inno Setup with three destination folders在这里不起作用。它应该是一个文本框和浏览按钮,可以选择多个文件。

解决方法

我使用Inno Setup 6.0.5(u)进行了测试。其他版本可能有所不同。

看看GetOpenFileNameMulti函数: 来自documentation

说明:
显示一个对话框,使用户可以选择一个或多个现有文件。如果用户选择了文件,则返回True,否则返回False。所选文件的名称将在FileNameList列表中返回。

备注:
过滤器示例:'文本文件( .txt)| .txt |所有文件()| '

示例:

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;

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...