这是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方法在这里不起作用。它应该是一个文本框和浏览按钮,可以选择多个文件。
我使用Inno Setup 6.0.5(u(进行了测试。其他版本可能有所不同。
查看GetOpenFileNameMulti
函数:来自文件:
描述:
显示一个对话框,使用户可以选择一个或多个现有文件。如果用户选择了一个文件,则返回True,否则返回False。所选文件的名称将在"文件名列表"列表中返回。备注:
示例筛选器:'文本文件(.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;