//取指定文件夾及其子文件夾內指定類型文件列表
procedure _GetFileList(AStrings: TStrings; ASourFile, FileName: string);
// 調用示例: _GetFileList(FileList, 'c:/', '*.pas')
var
sour_path, sour_file: string;
TmpList: TStringList;
FileRec, subFileRec: TSearchrec;
i: Integer;
begin
if rightStr(trim(ASourFile), 1) <> '/' then
sour_path := trim(ASourFile) + '/'
else
sour_path := trim(ASourFile);
sour_file := FileName;
if not DirectoryExists(sour_path) then
begin
AStrings.Clear;
exit;
end;
TmpList := TStringList.Create;
TmpList.Clear;
if FindFirst(sour_path + FileName, faAnyfile, FileRec) = 0 then
repeat
if ((FileRec.Attr and faDirectory) = 0) then
AStrings.Add(sour_path+FileRec.Name);
until FindNext(FileRec) <> 0;
if FindFirst(sour_path + '*.*', faAnyfile, FileRec) = 0 then
repeat
if ((FileRec.Attr and faDirectory) <> 0) then
begin
if ((FileRec.Name<> '.') and (FileRec.Name <> '..')) then
_GetFileList(AStrings, sour_path+ FileRec.Name + '/', sour_file);
end;
until FindNext(FileRec) <> 0;
FindClose(FileRec);
end;