SHGetSpecialFolderLocation
ExpandEnvironmentStrings
http://blog.csdn.net/wvw/article/details/5471611
用ExpandEnvironmentStrings 獲取 %appdata%
正常情況下沒問題, 但是當你的程序被外部程序啟動時, 可能會產生獲取錯誤的問題(非失敗). 比如system給你啟動.
http://blog.sina.com.cn/s/blog_4e4fba0401000ah2.html如何獲取臨時文件夾位置
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("臨時文件夾位于:"+StrPath,"提示信息",MB_OK);
}
pShellMalloc->Free(pidl);
pShellMalloc->Release();