1. 通过Windows的环境变量获得
具体请参考:
http://blog.csdn.net/mjw2607/archive/2009/04/15/4075625.aspx
2. 使用Windows API函数
BOOL SHGetSpecialFolderPath(HWND hwndOwner, LPTSTR lpszPath, int nFolder, BOOL fCreate);用法:TCHAR tsztest[MAX_PATH] = {0};BOOL bres = SHGetSpecialFolderPath(NULL, tsztest, CSIDL_PROGRAM_FILES, 0);
if (!bres)
{
OutputDebugString(TEXT("SHGetSpecialFolderPath Failed! \r\n"));
}OutputDebugString(tsztest);
more details please check following links:
http://blog.csdn.net/yincheng01/archive/2008/12/19/3556210.aspx