定义一个过程把它加到button的click事件中就好了。<br>var FSearchRec,DSearchRec:TSearchRec;<br>procedure TForm1.findfiles(APath:string);<br>var<br> FindResult:integer;<br>begin<br> findresult:=findfirst(Apath,faanyfile,fsearchrec);<br> try<br> while findresult=0 do<br> begin<br> if (fsearchrec.name<>'.')and(fsearchrec.name<>'..') then<br> begin<br> memo1.lines.loadfromfile(apath+fserachrec.name); <br> end;<br> findresult:=findnext(fsearchrec)<br> end;<br> findresult:=findfirst(apath+'*.txt',fadirectory,dsearchrec);<br> while findresult=0 do<br> findresult:=findnext(dsearchrec);<br> finally<br> findclose(fsearchrec);<br> end;<br>end;