unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 =
class(TForm)
ListBox1: TListBox;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure FindAllFiles(RootFolder:
string; Mask:
string = '
*.*'; Recurse: Boolean = True);
var
SR: TSearchRec;
begin
RootFolder := IncludeTrailingPathDelimiter(RootFolder);
if Recurse
then
if FindFirst(RootFolder + '
*.*', faAnyFile, SR) = 0
then
try
repeat
if SR.Attr
and faDirectory = faDirectory
then
if (SR.
Name <> '
.')
and (SR.
Name <> '
..')
then
FindAllFiles(RootFolder + SR.
Name, Mask, Recurse);
until FindNext(SR) <> 0;
finally
FindClose(SR);
end;
if FindFirst(RootFolder + Mask, faAnyFile, SR) = 0
then
try
repeat
if SR.Attr
and faDirectory <> faDirectory
then
begin
Form1.ListBox1.Items.Add(RootFolder + SR.
Name);
end;
until FindNext(SR) <> 0;
finally
FindClose(SR);
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
FindAllFiles('
c:\mp3s\', '
*.mp3', true);
end;
end.