unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,
ActiveX, ShlObj;
type
TForm1 =
class(TForm)
Button1: TButton;
ListBox1: TListBox;
procedure Button1Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
liste: TStringList;
implementation
{$R *.dfm}
procedure FindeDateien(aPath, aFindMask:
String; aWithSub: Boolean; aResult: tStrings);
Var
FindRec: tSearchRec;
Begin
If (aPath = '
')
or (aFindMask = '
')
or Not Assigned (aResult)
Then
Exit;
If aPath[Length (aPath)] <> '
\'
Then
aPath := aPath + '
\';
If FindFirst (aPath + aFindMask, faAnyFile, FindRec) = 0
Then
Repeat
If (FindRec.
Name <> '
.')
and (FindRec.
Name <> '
..')
Then
aResult.Add (aPath + FindRec.
Name);
Until FindNext (FindRec) <> 0;
FindClose (FindRec);
If Not aWithSub
Then
Exit;
If FindFirst (aPath + '
*.*', faAnyFile, FindRec) = 0
Then
Repeat
If (FindRec.
Name <> '
.')
and (FindRec.
Name <> '
..')
Then
If Boolean (FindRec.Attr
and faDirectory)
Then
FindeDateien (aPath + FindRec.
Name, aFindMask, aWithSub, aResult);
Until FindNext (FindRec) <> 0;
FindClose (FindRec);
End;
procedure TForm1.Button1Click(Sender: TObject);
var
x: integer;
begin
liste := tstringlist.create;
FindeDateien('
c:\Programme', '
*.*', True, liste);
for x := 0
to liste.count - 1
do
ListBox1.Items.Add(liste[x]);
end;
end.