VC中如何得到C:\Program Files的路径,在线等!谢谢!

解决方案 »

  1.   

    用一个折衷的办法,检查GetWindowsDirectory得到的windows路径,如果windows在D盘,那你需要的结果是 D:\Program Files
      

  2.   

    TCHAR tcProgramFile[MAX_PATH];
    SHGetSpecialFolderPath(NULL,tcProgramFile,CSIDL_PROGRAM_FILES,0);tcProgramFile中就是Program Files文件夹的路径了
      

  3.   

    你可以去MSDN里查下SHGetSpecialFolderPath这个API的用法,它可以得到大部分系统路径,如window,system等
      

  4.   

    你只要看第三个参数就好了,想要得到不同的文件夹路径,传入不同的参数就行。
    CSIDL_APPDATA  File system directory that serves as a common repository for application-specific data. CSIDL_DESKTOP  Not supported on Smartphone. CSIDL_FAVORITES  The file system directory that serves as a common repository for the user's favorite items. CSIDL_FONTS  The virtual folder that contains fonts. CSIDL_PERSONAL  The file system directory that serves as a common repository for documents. CSIDL_PROGRAM_FILES  The program files folder. CSIDL_PROGRAMS  The file system directory that contains the user's program groups, which are also file system directories. CSIDL_STARTUP  The file system directory that corresponds to the user's Startup program group. The system starts these programs when a device is powered on. 我想只看参数的名称你也能猜出是什么文件夹吧
    CSIDL_WINDOWS