unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,DateUtils, FileCtrl;
type
TFindFilesOption = (ffoExcludePath, ffoExcludeExt);
TFindFilesOptions =
set of TFindFilesOption;
TForm1 =
class(TForm)
ListBox1: TListBox;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
function FindFiles(
const fileExpr:
String; files: TStrings;options: TFindFilesOptions): Boolean;
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function TForm1.FindFiles(
const fileExpr:
String; files: TStrings;
options: TFindFilesOptions): Boolean;
var
sr2: TSearchRec;
path2:
string;
extWanted: Boolean;
begin
Result := True;
files.Clear;
files.BeginUpdate;
if ffoExcludePath
in options
then path2 := '
'
else path2 := ExtractFilePath(fileExpr);
extWanted :=
not (ffoExcludeExt
in options);
if FindFirst(fileExpr, faArchive, sr2) = 0
then
begin
repeat
if extWanted
then files.Add(path2 + sr2.
Name)
else files.Add(ChangeFileExt(path2 + sr2.
Name, '
'));
until FindNext(sr2) <> 0;
FindClose(sr2);
end else Result := False;
files.EndUpdate;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
FindFiles('
c:\WINDOWS\'+ '
\*', ListBox1.Items, [ffoExcludePath, ffoExcludeExt]);
end;
end.