Delphi 文件查找findfirst,findnext,findclose


本文整理自网络,侵删。

 

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;

type
TForm1 = class(TForm)
    Button1: TButton;
    ListBox1: TListBox;
    procedure Button1Click(Sender: TObject);
private
    { Private declarations }
public
    { Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

var
found:integer;
dirstr:string;
keyword:string;
rc:TSearchRec;

procedure TForm1.Button1Click(Sender: TObject);
var
s:string;
begin
dirstr:='c:\windows\'; //任意目录
keyword:='*.exe'; //关键字
s:=dirstr+Trim(keyword); //网上说去与结果不符的项 例如 _.exe~ 等等
found:=findfirst(s,faAnyFile,rc);
while found=0 do
begin
      if (rc.Attr and faDirectory) <> 0 then       // 判断目录
        found:=FindNext(rc)
      else
        begin
          listbox1.Items.Add(rc.Name); //do samething...
          found:=FindNext(rc);
        end

end;
end;

end.

相关阅读 >>

Delphi tfilestream 流操作2

开源Delphi组件,框架,库,资源等。

Delphi 中压缩流和解压流的应用

Delphi 判断timage是否为空及注意事项

Delphi 三层架构简单例子(经测试成功)

Delphi实时监视应用程序内存使用量

Delphi 如何读取内存中的数据?

Delphi adoquery添加用户及密码

Delphi thread.queue与synchronize的区别

Delphi thttprio 控件调用webservice超时问题

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



打赏

取消

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

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

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

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

评论

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