1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
| unit Unit1;
interface
uses
Messages, SysUtils, Windows, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
string4 = String[4];
TForm1 = class(TForm)
Edit1: TEdit;
Button1: TButton;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
Function Recherche(mot:string;ext:string4;list:TStrings):integer;
private
{ Déclarations privées }
public
{ Déclarations publiques }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var Files: String; PropF: TSearchRec;
label FNext;
begin
Memo1.Clear;
Recherche(Edit1.Text,'.txt',Memo1.Lines);
end;
Function TForm1.Recherche(mot:string;ext:string4;list:TStrings):integer;
var
h:Thandle ;
sr: TWin32FindData;
c:integer;
begin
h:=Windows.FindFirstFile(pchar(mot+ext), sr);
//sr.dwFileAttributes :=$3F;
c:=0;
if h <> INVALID_HANDLE_VALUE then
begin
repeat
if ((sr.dwFileAttributes or 3)=3) or (sr.dwFileAttributes =$20) then
begin
inc(c);
List.Add(string(sr.cFileName) );
end;
until not Windows.FindNextFile(h,sr);
Windows.FindClose(h);
end;
result:=c ;
end;
end. |
Partager