1. 获得如下目录:"C:\Documents and Settings\robert\Application Data"
#include "shlobj.h"
int main(int argc, char* argv[])
{
char szPath[MAX_PATH];
if(SUCCEEDED(SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, 0, szPath)))
{
printf("%s\n", szPath);
}
return 0;
}
2. 获得如下目录:"C:\Documents and Settings\robert"
#include "userenv.h"
int main(int argc, char* argv[])
{
char szPath[MAX_PATH];
GetUserProfileProperty(NULL, szPath, MAX_PATH)))
{
printf("%s\n", szPath);
}
return 0;
}