/** * @brief Get the home directory in Application Data * @note Forced for Windows Vista * @note Use the cvar fs_usehomedir if you want to use the homedir for other * Windows versions, too */ char *Sys_GetHomeDirectory (void) { TCHAR szPath[MAX_PATH]; static char path[MAX_OSPATH]; FARPROC qSHGetFolderPath; HMODULE shfolder; shfolder = LoadLibrary("shfolder.dll"); if (shfolder == NULL) { Com_Printf("Unable to load SHFolder.dll\n"); return NULL; } qSHGetFolderPath = GetProcAddress(shfolder, "SHGetFolderPathA"); if (qSHGetFolderPath == NULL) { Com_Printf("Unable to find SHGetFolderPath in SHFolder.dll\n"); FreeLibrary(shfolder); return NULL; } if (!SUCCEEDED(qSHGetFolderPath(NULL, CSIDL_APPDATA, NULL, 0, szPath))) { Com_Printf("Unable to detect CSIDL_APPDATA\n"); FreeLibrary(shfolder); return NULL; } Q_strncpyz(path, szPath, sizeof(path)); Q_strcat(path, "\\UFOAI", sizeof(path)); FreeLibrary(shfolder); if (!CreateDirectory(path, NULL)) { if (GetLastError() != ERROR_ALREADY_EXISTS) { Com_Printf("Unable to create directory \"%s\"\n", path); return NULL; } } return path; }