Hallo,
ich habe die Prozedur ein wenig abgeändert:
Delphi-Quellcode:
procedure GetSubDirs(const sRootDir: string; slDirectories: TStrings);
var
srSearch: TSearchRec;
sSearchPath: string;
// slSub: TStrings;
begin
Screen.Cursor := crHourGlass;
// slSub := TStringList.Create;
slDirectories.BeginUpdate;
slDirectories.Clear;
try
sSearchPath := IncludeTrailingBackslash(sRootDir);
if FindFirst(sSearchPath + '*', faDirectory, srSearch) = 0 then
begin
repeat
if ((srSearch.Attr and faDirectory) = faDirectory) and
(srSearch.Name <> '.') and
(srSearch.Name <> '..') then begin
slDirectories.Add(sSearchPath + srSearch.Name);
// slSub.Add(sSearchPath + srSearch.Name);
end;
until
(FindNext(srSearch) <> 0);
FindClose(srSearch);
end;
finally
slDirectories.EndUpdate;
// FreeAndNil(slSub);
Screen.Cursor := crDefault;
end;
end;
Aufrufen kannst Du sie z.B. so:
GetSubDirs('C:\Programme',Memo1.Lines);
//Edit: IncludeTrailingBackslash an die richtige Stelle gesetzt