用三个函数:
FindFirst
FindNext
FindClose
可以将一个目录下所有的指定类型文件列出来
例子:
var
SearchRec: TSearchRec;
procedure TForm1.SearchClick(Sender: TObject);
begin
FindFirst('c:/Program Files/delphi4/bin/*.*', faAnyFile, SearchRec);
Label1.Caption := SearchRec.Name + ' is ' + IntToStr(SearchRec.Size) + ' bytes in size';
end;
procedure TForm1.AgainClick(Sender: TObject);
begin
if (FindNext(SearchRec) = 0)
Label1.Caption := SearchRec.Name + ' is ' + IntToStr(SearchRec.Size) + ' bytes in size';
else
FindClose(SearchRec);
end;
用一个递归调用,就可以做全盘搜索了。