可以使用FINDFIRST函数和FINDNEXT函数。
函数原型为:
function FindFirst(const Path: string; Attr: Integer; var F: TSearchRec): Integer;
描述:
FindFirst searches the directory specified by Path
for the first file that matches the file name implied by Path
and the attributes specified by the Attr parameter.
The result is returned in the F parameter.
Use the fields of this search record to extract the information needed.
FindFirst returns 0 if a file was successfully located,
otherwise, it returns an error code.
下面是TSearchRec的类型定义。
type
TSearchRec = record
Time: Integer;
Size: Integer;
Attr: Integer;
Name: TFileName;
ExcludeAttr: Integer;
FindHandle: THandle;
FindData: TWin32FindData;
end;
文件名就在NAME中存放着。
具体的情况还要你自己多多的去看DELPHI中的文档!