各位帮忙!扫描所有硬盘,搜索某一类型的文件,扫描程序怎么写?有没有源码?感激不尽

解决方案 »

  1.   

    用FindFirstFile()、FindNextFile()、FindClose()来写就可以。
      

  2.   

    强列推荐多线程。
    FindFirstFile()、FindNextFile()、FindClose()(MFC)
      

  3.   

    //copy from MSDN
    This small program recurses every directory on the C:\ drive and prints the name of the directory.#include <afx.h>
    #include <iostream>using namespace std;void Recurse(LPCTSTR pstr)
    {
       CFileFind finder;   // build a string with wildcards
       CString strWildcard(pstr);
       strWildcard += _T("\\*.*");   // start working for files
       BOOL bWorking = finder.FindFile(strWildcard);   while (bWorking)
       {
          bWorking = finder.FindNextFile();      // skip . and .. files; otherwise, we'd
          // recur infinitely!      if (finder.IsDots())
             continue;      // if it's a directory, recursively search it      if (finder.IsDirectory())
          {
             CString str = finder.GetFilePath();
             cout << (LPCTSTR) str << endl;
             Recurse(str);
          }
       }   finder.Close();
    }void main()
    {
       if (!AfxWinInit(GetModuleHandle(NULL), NULL, GetCommandLine(), 0)
          cout << "panic!" << endl;
       else
          Recurse(_T("C:"));
    }
      

  4.   

    采用递归函数
    GetFile(CString sDir)
    {
    CFileFine ff;
    BOOL bContinue = ff.FindFile(sDir+"\\*.*");
             //把*.*改成别的扩展名,就实现了文件的过滤 while(bContinue)
    {
    bContinue = ff.FindNextFile();
    if(ff.IsDots())//这是 . 和 ..
     continue;
    if(ff.IsDirectory())//这是目录,遍历这个目录
    GetFile(ff.GetFilePath());
    else//这是文件,可以往数据库里存了
    {
    CString sFileName = ff.GetFilePath();
    } }
             ff.Close();
    }然后调用,比如GetFile("c:")就可以了可以参考帖子
    http://expert.csdn.net/Expert/topic/1975/1975673.xml?temp=.1268122