你自己看看吧。没有整理的,是从我的一个Tool.pas中摘录下来的,是一个通用的文件查找函数,支持回调。
procedure FindFile(var quit:boolean;const path: String;const filename:string='*.*';
                   proc:TFindCallBack=nil;bSub:boolean=true);
var
  fpath: String;
  info: TsearchRec; procedure ProcessAFile;
 begin
  if (info.Name<>'.') and (info.Name<>'..') and ((info.Attr and faDirectory)<>faDirectory) then
  begin
  if assigned(proc) then
    proc(info,quit,bsub);
  end;
 end; procedure ProcessADirectory;
 begin
  if (info.Name<>'.') and (info.Name<>'..') and ((info.attr and fadirectory)=fadirectory) then
    findfile(quit,fpath+info.Name,filename,proc,bsub);
 end;begin
if quit then  exit;
fpath:=string(pchar(path));
if path[length(fpath)]<>'\' then
  fpath:=fpath+'\';
try
  if 0=findfirst(fpath+filename,faanyfile and (not fadirectory),info) then
  begin
    ProcessAFile;
    while 0=findnext(info) do
      begin
        if quit then
          begin
            findclose(info);
            exit;
          end;
        ProcessAFile;
      end;
  end;
finally
  findclose(info);
end;
try
  if bsub and (0=findfirst(fpath+'*',faanyfile,info)) then
    begin
      ProcessADirectory;
      while findnext(info)=0 do
        ProcessADirectory;
    end;
finally
  findclose(info);
end;
end;