delphi中如何实现模糊查找文件


本文整理自网络,侵删。

 
procedure   GetFilenames(sPath,   sFilename:   String;     AList:   TStrings);
//功能描述:   列出sPath目录中(不含子目录)所有文件名符合sFilename规则的文件名
//入口参数:
//     sPath           -   目录路径
//     sFilename   -   文件名
//出口参数:
//     AList           -   sPath目录中所有符合的文件名被添加到了这一列表中
var
   SR   :   TSearchRec;
begin
   if   FindFirst(sPath   +   sFilename,   faReadOnly   +   faHidden   +   faSysFile   +  faArchive   +   faAnyFile,   SR)   =   0   then
   begin
       repeat
           AList.Add(sPath   +   SR.Name);
       until   FindNext(SR)   <>   0;
       FindClose(SR);
   end;
end;

调用举例:   在ListBox1中列出   d:\aaa*.*
GetFilenames   ( 'd:\ ',   'aaa*.* ',   ListBox1.Items);

相关阅读 >>

Delphi 分割字符串 extractstrings

Delphi 按钮躲避鼠标点击

Delphi 遍历系统窗口标题可用于反外挂反破解

Delphi 10.4 freeandnil 问题

Delphi和c++指针详解

Delphi 如何编写使stringgrid中的一列具有check功能,和checkbox效果一样

什么是嵌入式数据库

Delphi hash md5

Delphi hook 指定程序窗体和控件的 wndproc

Delphi线程中关闭程序

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...