- // Best solution is to set fg-home to My Documents but it requires reading the Windows registry
- bool fg_home_set = false;
- HKEY hKey;
- LONG rc = RegOpenKeyEx( HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders", 0, KEY_QUERY_VALUE, &hKey );
- if ( rc == ERROR_SUCCESS ) {
- DWORD vt,bs;
- rc = RegQueryValueEx( hKey, "Personal", NULL, &vt, NULL, &bs );
- if ( rc == ERROR_SUCCESS ) {
- unsigned char *buff = new unsigned char[ bs ];
- rc = RegQueryValueEx( hKey, "Personal", NULL, &vt, buff, &bs );
- fgSetString("/sim/fg-home", (char *)buff);
- fg_home_set = true;
- delete [] buff;
- }
- RegCloseKey( hKey );
- }
- char *envp = ::getenv( "APPDATA" ); // APPDATA is for applications and is hidden