用以下的函数会返回FALSE
if (::SHGetSpecialFolderPath (NULL,strPath.GetBuffer(MAX_PATH),0x0026,FALSE ))
{
}
else
{
DWORD dwError=::GetLastError();

}
dwError返回0

解决方案 »

  1.   

    UINT GetWindowsDirectory(
      LPTSTR lpBuffer,
      UINT uSize
    );
    然后再加上Program files
      

  2.   

    GetWindowsDirectory得到是Windows所在的路径,比方说“C:\WINNT”,如果你用得到的结果再加上Program Files不一定对。只有Windows的安装目录是根目录的时候,才是对的。
      

  3.   

    LPITEMIDLIST ppidl;    //定义IDLIST指针    char linkpath[255];   //定义字符串,保存目录名     SHGetSpecialFolderLocation(NULL,CSIDL_PROGRAMS ,&ppidl);     SHGetPathFromIDList(ppidl,linkpath);