Delphi-Quellcode:
procedure TForm1.Button1Click(Sender: TObject);
begin
DirectoryListing('C:/*',Listbox1.Items);
end;
procedure TForm1.DirectoryListing(const PATH:String;SL:TStrings);
var
S : TSearchRec;
begin
if FindFirst(PATH, faDirectory, S) = 0 then
begin
repeat
if (S.Attr and faDirectory) = S.Attr then
if (S.Name<>'.') and (S.Name<>'..') then SL.Add(S.Name)
until FindNext(S) <> 0;
FindClose(S);
end;
if Result.Count = 0 then SL.Add(format('%s enthält keine Ordner', [path]));
end;
// nur aus dem Kopf getippt