你自己看看吧。没有整理的,是从我的一个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;
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;
解决方案 »
- 锁定FORM问题即使鼠标双击也不能改变窗口大小!
- 初学者
- 关于inno setup中的dll注册
- 这段时间要用 delphi写一个ActiveX ,其中用到XML交互,所以写了一个TXmlHelper类,和大家共享,并希望大家提出修改意见
- 關於如何截取字符串的問題,請幫忙???
- 关于动态创建菜单时,动态打开窗口的问题
- sql语句中,类型不匹配
- 谢谢大家 再给大家一百 分 谢谢 ~~~!!!!!,明天8点揭贴
- 有没有详细一点介绍Teechart控件三位建模的资料啊
- 那里有delphi基本组件的详细资料
- 菜鸟提问,TListView如何用,如何动态的添加Items和SubItems?
- 如何动态使用构件和控件
2。自己写递归函数,自己动脑筋
3。用MDB格式,即ACCESS带的数据库格式
4。ADO是数据库连接方式不是数据库,ADO是微软最新的数据库连接方式,是以后数据库连接的新标准。