代码如下:

procedure TForm1.N9Click(Sender: TObject);
//查找指定文件 FileSearch
var
  FileName,Dir,s: string;
begin
  FileName := 'notepad.exe'; // 要找的文件
  Dir := 'c:\windows';      //指定在哪个目录查找
  s := FileSearch(FileName,Dir);

  if s<>'' then  //如果上面的函数返回值不为空,则..否则..
    ShowMessage(s)  //c:\windows\notepad.exe
  else
    ShowMessage('没找到');
end;

 

下面进行函数分析:

function FileSearch(const Name,   //要查找文件的文件名
                    DirList: string  //指定在哪个目录查找
                   ): string;  //如果函数成功,返回一个包含路径文件名的字符串,否则返回空串
posted on 2010-11-02 17:03  巅枫  阅读(379)  评论(0编辑  收藏  举报