SHGetSpecialFolderLocation
ExpandEnvironmentStrings
http://blog.csdn.net/wvw/article/details/5471611
用ExpandEnvironmentStrings 獲取 %appdata%
正常情況下沒問(wèn)題, 但是當(dāng)你的程序被外部程序啟動(dòng)時(shí), 可能會(huì)產(chǎn)生獲取錯(cuò)誤的問(wèn)題(非失敗). 比如system給你啟動(dòng).
http://blog.sina.com.cn/s/blog_4e4fba0401000ah2.html如何獲取臨時(shí)文件夾位置
char Path[MAX_PATH];
CString StrPath;
LPITEMIDLIST pidl;
LPMALLOC pShellMalloc;
if(SUCCEEDED(SHGetMalloc(&pShellMalloc)))
if(SUCCEEDED(SHGetSpecialFolderLocation(NULL,CSIDL_TEMPLATES,&pidl)))
if(SHGetPathFromIDList(pidl,Path))
{
StrPath.Format("%s",Path);
MessageBox("臨時(shí)文件夾位于:"+StrPath,"提示信息",MB_OK);
}
pShellMalloc->Free(pidl);
pShellMalloc->Release();