| The following example lists all files and subdirectories of the C:Windows directory into a TListBox called ListBox1:
Usage: FindAll('C:Windows*.*',faAnyFile,ListBox1.Items)
Followings are the source code for FindAll procedure.
procedure FindAll (const Path: String; Attr: Integer; List: TStrings) ;
var
Res: TSearchRec;
EOFound: Boolean;
begin
EOFound:= False;
if FindFirst(Path, Attr, Res) < 0 then
exit
else
while not EOFound do begin
List.Add(Res.Name) ;
EOFound:= FindNext(Res) <> 0;
end;
FindClose(Res) ;
end; |