如题
解决方案 »
- 关于图片拖动操作
- 带复选框的TreeView
- 为什么在同一按钮中建立socket连接后,第一次总是发不出去,源代码如下:
- 执行dpr文件提示: File not found: 'wwrcdpnl.dcu'
- 怎样得到电视节目表?
- 为什么SqlServer 升级到sp3后,delphi5 ado 访问数据库时不能写
- 一个关于treeview节点的修改的问题,怎样修改一个节点使其所有的子节点自动修改?
- 为什么我删除一个表的所有记录后,会出现错误提示呢?
- 提个有意思的小问题!!!
- image1.Picture.Bitmap.LoadFromResourceID()怎么用?
- 雅戈尔的阴险
- idudpserver发送数据的事!
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, StrUtils, ExtCtrls;type
TfrmMain = class(TForm)
pnlClient: TPanel;
memSearchResult: TMemo;
pnlTop: TPanel;
lblSearchPath: TLabel;
lblSearchFile: TLabel;
lblSearchResult: TLabel;
edtSearchPath: TEdit;
btnStartSearch: TButton;
edtSearchFile: TEdit;
procedure btnStartSearchClick(Sender: TObject);
private
{ Private declarations }
procedure GetFilenames(sPath, sFilename: String; AList: TStrings);
procedure Search(sPath, sFilename: String; AList: TStrings);
public
{ Public declarations }
end;var
frmMain: TfrmMain;implementation{$R *.dfm}procedure TfrmMain.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;procedure TfrmMain.Search(sPath, sFilename: String; AList: TStrings);
//功能描述: 遍历sPath目录及其子目录中所有的文件名符合sFilename规则的文件名
//入口参数:
// sPath - 目录路径
// sFilename - 文件名
//出口参数:
// AList - 所有符合的文件名被添加到了这一列表中
var
SR: TSearchRec;
begin
GetFilenames(sPath, sFilename, AList);
if FindFirst(sPath + '*.*' , faReadOnly + faHidden + faArchive + faDirectory, SR) = 0 then
begin
repeat
if (SR.Attr and faDirectory) = faDirectory then
begin
if (SR.Name <> '.') and (SR.Name <> '..') then
begin
Search(sPath + sR.Name + '\', sFilename, AList);
end;
end;
until FindNext(SR) <> 0;
FindClose(SR);
end;
end;procedure TfrmMain.btnStartSearchClick(Sender: TObject);
//事件描述: 开始查找
var
sPath : String;
begin
memSearchResult.Lines.Clear;
sPath := edtSearchPath.Text;
//保证sPath的最后一个字符为'\'
if RightStr(sPath, 1) <> '\' then sPath := sPath + '\';
Search (sPath, edtSearchFile.Text, memSearchResult.Lines);
end;end.