请问如何获取程序路径,想做一个类似桌面的程序,需要得到系统里所有可执行程序的路径(不是进程,程序可能并没有运行),比如安装的QQ的路径,360的路径,VC++的路径等等,,请指教,,谢谢~

解决方案 »

  1.   

    void Recurse(LPCTSTR pstr)
    {
      CFileFind finder;  // build a string with wildcards
      CString strWildcard(pstr);
      strWildcard += "\\*.exe";  // 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();
      TRACE(_T("%s
    "), (LPCTSTR)str);
      Recurse(str);
      }
      }  finder.Close();
    }调用的时候:
    Recurse(_T("C:"));
    实现遍历C盘下的所有exe文件
      

  2.   

    谢谢大家的回答,另外还想请教一下,注册表下的
    HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths
    这个键是不是跟系统的应用程序有关呢?为什么像360的路径可以在里面找到,而QQ之类的却没有呢?