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();