gpt4 book ai didi

inno-setup - Inno Setup : List all file names in an directory

转载 作者:行者123 更新时间:2023-12-04 17:01:02 28 4
gpt4 key购买 nike

我正在尝试列出目录中具有名称的所有文件,但无法执行。有什么办法可以列出目录中所有带有名称的文件?

提前致谢。

最佳答案

以下脚本显示了如何将指定目录的所有文件列出到TStrings集合中(在此示例中,在自定义页面的列表框中列出):

[Code]
procedure ListFiles(const Directory: string; Files: TStrings);
var
FindRec: TFindRec;
begin
Files.Clear;
if FindFirst(ExpandConstant(Directory + '*'), FindRec) then
try
repeat
if FindRec.Attributes and FILE_ATTRIBUTE_DIRECTORY = 0 then
Files.Add(FindRec.Name);
until
not FindNext(FindRec);
finally
FindClose(FindRec);
end;
end;

procedure InitializeWizard;
var
CustomPage: TWizardPage;
FileListBox: TNewListBox;
begin
CustomPage := CreateCustomPage(wpWelcome, 'Caption', 'Description');
FileListBox := TNewListBox.Create(WizardForm);
FileListBox.Parent := CustomPage.Surface;
FileListBox.Align := alClient;

ListFiles('C:\SomeDirectory\', FileListBox.Items);
end;

关于inno-setup - Inno Setup : List all file names in an directory,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19808068/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com