unit unit1;
interface
uses
windows, messages, sysutils, variants, classes, graphics, controls, forms,
dialogs, stdctrls, extctrls, filectrl;
type
tform1 = class(tform)
directorylistbox1: tdirectorylistbox;
labelededit1: tlabelededit;
button1: tbutton;
listbox1: tlistbox;
drivecombobox1: tdrivecombobox;
button2: tbutton;
procedure button1click(sender: tobject);
procedure button2click(sender: tobject);
private
{ private declarations }
public
procedure findfiles(apath:string;afile:string);
{ public declarations }
end;
var
form1: tform1;
targetfiles:string;
implementation
{$r *.dfm}
procedure tform1.button1click(sender: tobject);
begin
screen.cursor:=crhourglass;
try
listbox1.clear;
targetfiles:=labelededit1.text;
findfiles(directorylistbox1.directory,targetfiles);
finally
screen.cursor:=crdefault;
end;
end;
procedure tform1.findfiles(apath,afile:string);
var
findresult:integer;
fsearchrec,dsearchrec:tsearchrec;
function isdirnotation(adirname:string):boolean;
begin
result:=((adirname='.') or (adirname='..'));
end;
begin
if apath[length(apath)]<>'\' then
apath:=apath+'\';
findresult:=findfirst(apath+afile,faanyfile+fahidden+fasysfile+fareadonly,fsearchrec);
try
while findresult=0 do begin
listbox1.items.add(fsearchrec.name);
findresult:=findnext(fsearchrec);
end;
findresult:=findfirst(apath+'*.*',fadirectory,dsearchrec);
while findresult=0 do begin
if((dsearchrec.attr and fadirectory)= fadirectory) and
not isdirnotation(dsearchrec.name) then
findfiles(apath+dsearchrec.name,targetfiles);
findresult:=findnext(dsearchrec);
end;
finally
findclose(fsearchrec);
end;
end;
procedure tform1.button2click(sender: tobject);
begin
listbox1.items.add('aa');
end;
end.