delphi文件搜索多线程
发布时间:2020-12-15 04:31:25 所属栏目:大数据 来源:网络整理
导读:如果我执行它,我的应用程序将不会响应,直到找到所有文件和他们到列表框 我的问题是如何使这个功能多线程,以避免不相应的情况!我仍然是Delphi novoice procedure TfrMain.FileSearch(const PathName,FileName : string; txtToSearch : string; const InDir :
如果我执行它,我的应用程序将不会响应,直到找到所有文件和他们到列表框
我的问题是如何使这个功能多线程,以避免不相应的情况!我仍然是Delphi novoice procedure TfrMain.FileSearch(const PathName,FileName : string; txtToSearch : string; const InDir : boolean); var Rec : TSearchRec; Path : string; txt : string; fh : TextFile; i : integer; begin Path := IncludeTrailingBackslash(PathName); if FindFirst(Path + FileName,faAnyFile - faDirectory,Rec) = 0 then try repeat AssignFile(fh,Path + Rec.Name); Reset(fh); Readln(fh,txt); if ContainsStr(txt,txtToSearch) then ListBox1.Items.Add(Path + Rec.Name); until FindNext(Rec) <> 0; finally FindClose(Rec); end; If not InDir then Exit; if FindFirst(Path + '*.*',faDirectory,Rec) = 0 then try repeat if ((Rec.Attr and faDirectory) <> 0) and (Rec.Name<>'.') and (Rec.Name<>'..') then FileSearch(Path + Rec.Name,FileName,txtToSearch,True); until FindNext(Rec) <> 0; finally FindClose(Rec); end; end; 解决方法
Here您可以找到有关使用
OmniThreadLibrary实现的后台文件扫描程序的文章.
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |