procedure FindAllDir(const parentDir:string;List:TStrings;const recursively:Boolean=False); //获取所有子文件夹
var
hFindFile: THandle;
FindFileData: WIN32_FIND_DATA;
FullName,FName,s:string;
begin
//ShowMessage(dir);
s:=IncludeTrailingPathDelimiter(parentDir);
hFindFile := FindFirstFile(pchar(s+'*.*'), FindFileData); {便利所有文件 *.*}
if hFindFile <> 0 then begin
repeat
FName:=FindFileData.cFileName;
FullName:=s+FName;
if (FName='.') or (FName='..') then continue;
if ((FindFileData.dwFileAttributes and FILE_ATTRIBUTE_DIRECTORY) = FILE_ATTRIBUTE_DIRECTORY) then //如果是目录
begin
List.Add(FullName);
if recursively then
FindAllDir(FullName,List,recursively);
end;
until FindNextFile(hFindFile, FindFileData) = false;
windows.FindClose(hFindFile);
end;
end;