#include <shlobj.h>
#pragma comment(lib,"shell32.lib")
TCHAR szPath[MAX_PATH];
ZeroMemory(szPath, MAX_PATH);
SHGetSpecialFolderPath(NULL, szPath, CSIDL_APPDATA, FALSE);
在win7下,szPath为: C:\Users\用户\AppData\Roaming
在winxp下, szPath为: C:\Document and Settings\用户\Application Data
#pragma comment(lib,"shell32.lib")
TCHAR szPath[MAX_PATH];
ZeroMemory(szPath, MAX_PATH);
SHGetSpecialFolderPath(NULL, szPath, CSIDL_APPDATA, FALSE);
在win7下,szPath为: C:\Users\用户\AppData\Roaming
在winxp下, szPath为: C:\Document and Settings\用户\Application Data