mirror of
https://github.com/BeamMP/BeamMP-Launcher.git
synced 2026-02-16 10:40:46 +00:00
Fix for custom document location
This commit is contained in:
@@ -22,16 +22,19 @@ std::string GetGamePath(){
|
||||
LPCTSTR sk = "Software\\BeamNG\\BeamNG.drive";
|
||||
LONG openRes = RegOpenKeyEx(HKEY_CURRENT_USER, sk, 0, KEY_ALL_ACCESS, &hKey);
|
||||
if (openRes != ERROR_SUCCESS){
|
||||
fatal("Please launch the game at least once");
|
||||
fatal("Please launch the game at least once!");
|
||||
}
|
||||
Path = QueryKey(hKey,4);
|
||||
|
||||
if(Path.empty()){
|
||||
size_t RS;
|
||||
getenv_s(&RS, nullptr, 0, "USERPROFILE");
|
||||
std::string P(RS-1,0);
|
||||
getenv_s(&RS, &P[0], RS, "USERPROFILE");
|
||||
Path = P + R"(\Documents\BeamNG.drive\)";
|
||||
sk = R"(SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders)";
|
||||
|
||||
openRes = RegOpenKeyEx(HKEY_CURRENT_USER, sk, 0, KEY_ALL_ACCESS, &hKey);
|
||||
if (openRes != ERROR_SUCCESS){
|
||||
fatal("Cannot get Documents directory!");
|
||||
}
|
||||
Path = QueryKey(hKey,5);
|
||||
Path += "\\";
|
||||
return Path;
|
||||
}
|
||||
|
||||
|
||||
@@ -117,6 +117,7 @@ std::string QueryKey(HKEY hKey,int ID){
|
||||
case 2: if(key == "Name" && data == "BeamNG.drive")return data;break;
|
||||
case 3: if(key == "rootpath")return data;break;
|
||||
case 4: if(key == "userpath_override")return data;
|
||||
case 5: if(key == "Personal")return data;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user