function GetChildDir(const AParentDir: string): Tstringlist;
var
Dir: TSearchRec;
Ret: integer;
Path: string;
begin
Result:=Tstringlist.Create;
try
Path := ExtractFilePath(AParentDir);
Ret := Sysutils.FindFirst(AParentDir, faAnyFile, Dir);
if Ret <> NO_ERROR then exit;
try
while ret=NO_ERROR do
begin
if (Dir.Attr in [faDirectory]) and (Dir.Name[1] <> '. ') then
begin
Result.Add(Dir.name);
Result.addstrings(GetChildDir(Path + Dir.Name + '\*.* '));
end;
Ret := Sysutils.FindNext(Dir);
end;
finally
Sysutils.FindClose(Dir);
end;
except
Result.Free;
end;
end;
调用这个函数,再把返回值读入LISTBOX就可以了。
|
请发表评论