FindFirstFile VB声明 
Declare Function FindFirstFile Lib "kernel32" Alias "FindFirstFileA" (ByVal lpFileName As String, lpFindFileData As WIN32_FIND_DATA) As Long 
说明 
根据文件名查找文件 
返回值 
Long,如执行成功,返回一个搜索句柄。如果出错,返回一个INVALID_HANDLE_VALUE常数,一旦不再需要,应该用FindClose函数关闭这个句柄 
参数表 
参数 类型及说明 
lpFileName String,欲搜索的文件名。可包含通配符,并可包含一个路径或相对路径名 
lpFindFileData WIN32_FIND_DATA,这个结构用于装载与找到的文件有关的信息。该结构可用于后续的搜索 
注解 
由这个函数返回的句柄可以作为一个参数用于FindNextFile函数。这样一来,就可以方便的枚举出与lpFileName参数指定的文件名相符的所有文件
 FindNextFile VB声明 
Declare Function FindNextFile Lib "kernel32" Alias "FindNextFileA" (ByVal hFindFile As Long, lpFindFileData As WIN32_FIND_DATA) As Long 
说明 
根据调用FindFirstFile函数时指定的一个文件名查找下一个文件 
返回值 
Long,非零表示成功,零表示失败。如不再有与指定条件相符的文件,会将GetLastError设置成ERROR_NO_MORE_FILES 
参数表 
参数 类型及说明 
hFindFile Long,由FindFirstFile函数返回的搜索句柄 
lpFindFileData WIN32_FIND_DATA,这个结构用于装载与找到的文件有关的信息 

解决方案 »

  1.   

    //希望能给你一些帮助,这是搜索硬盘中的全部*.swf,*.exe文件
    //在windows目录中有一个scanswf.ini文件,可以修改这个文件
    //达到一些其它的查找目的
    ///////////////////////////////////////////////////
    private
        { Private declarations }
        procedure scan_tree (root: string);
      public
        { Public declarations }
        names_count:integer;
        names:tstrings;
        dnames:tstrings;
      end;var
      Form3: TForm3;
      stop_requested: boolean;
      scanning: boolean;
      inifile:tinifile;implementation{$R *.dfm}
    ///////////////////////搜索硬盘/////////////////////////
    constnormal_names: array [1..2] of string =
        ('*.swf',
         '*.exe');
    procedure TForm3.scan_tree (root: string);
    var
      test_name: string;
      full_name: string;
      s: TSearchRec;
      wanted: integer;
    begin
      if stop_requested then Exit;
      root := LowerCase (root);
      if root [Length (root)] <> '\' then
         root := root + '\';
      for wanted := 0 to names_count-1 do  begin
          Application.ProcessMessages;
          test_name := root + names[wanted];
          if FindFirst (test_name, faAnyFile, s) = 0 then
             repeat
                   if stop_requested then Exit;
                   with s do begin
                        Name := LowerCase (Name);
                        if (Attr <> faDirectory) then  begin
                            full_name := root + Name;
                            listbox1.Items.Add(full_name);
                            
                        end;
                   end;
             until FindNext (s) <> 0;
          FindClose (s);
      end;
      test_name := root + '*.*';
      if FindFirst (test_name, faAnyFile, s) = 0 then
         repeat
               with s do
                    if ((Attr and faDirectory) <> 0) and ((Name <> '.') and (Name <> '..'))
                    then scan_tree (root + Name);
         until FindNext (s) <> 0;
      FindClose (s);
    end;
    ////////////////////////////////////////////////////////////
    procedure TForm3.FormCreate(Sender: TObject);
    var
       p:pchar;i:integer;filename:string;
    begin
    ////////////////////搜索硬盘的准备工作//////////////////////////////
    names:=tstringlist.Create;
      dnames:=tstringlist.Create;
      getmem(p,255);
      getwindowsdirectory(p,255);
      filename:=p+'\scanswf.ini';
      freemem(p);
      scanning := False;
      stop_requested := False;
      for i:=1 to  2 do
          dnames.Append(normal_names[i]);
      if fileexists(filename) then
         names.LoadFromFile(filename)
      else begin
           names:=dnames;
           names.SaveToFile(filename);
      end;
      names_count:=names.Count;
    //////////////////////////////////////////////////
    end;procedure TForm3.N2Click(Sender: TObject);
    var i:char;drive:string;
    begin
    //搜索全部的硬盘
    if scanning then begin
         stop_requested := True;
      end
      else begin
         listbox1.Items.Clear;
         scanning := True;
         stop_requested := False;
         try
             for i:='a' to 'z' do begin
                 drive:=i+':\';
                 if getdrivetype(pchar(drive))=DRIVE_FIXED then
                    scan_tree (drive);
             end;
         finally
         end;
         scanning := False;
      end;
    end;
      

  2.   

    上面给我的都是只能查找纯文本文件(TXT文件),对于WORD、RTF等却无能为力。WIN2000里的搜索可以实现,它的API或DLL在哪呢?急呀!!!!!!
      

  3.   

    试一试 Word 里面的 API首先建立一个OLECreateOleObject然后关联到你需要的word,再使用里面的搜索吧。具体我也不记得了。 好运。
      

  4.   

    自己把Explorer.exe文件反编译一下不就知道了它调用过的API!^_^
      

  5.   

    xiaoxingchi(第007元素) 应该正确我BCB在做过