mirror of
https://github.com/BeamMP/BeamMP-Launcher.git
synced 2025-07-01 23:46:59 +00:00
Get localappdata via winapi instead of registry
This commit is contained in:
parent
7600372ca1
commit
1d7eb64fe0
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
#include <shlobj.h>
|
||||||
#elif defined(__linux__)
|
#elif defined(__linux__)
|
||||||
#include "vdf_parser.hpp"
|
#include "vdf_parser.hpp"
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
@ -40,17 +41,17 @@ std::string GetGamePath() {
|
|||||||
Path = QueryKey(hKey, 4);
|
Path = QueryKey(hKey, 4);
|
||||||
|
|
||||||
if (Path.empty()) {
|
if (Path.empty()) {
|
||||||
sk = R"(SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders)";
|
Path = "";
|
||||||
openRes = RegOpenKeyEx(HKEY_CURRENT_USER, sk, 0, KEY_ALL_ACCESS, &hKey);
|
char appDataPath[MAX_PATH];
|
||||||
if (openRes != ERROR_SUCCESS) {
|
HRESULT result = SHGetFolderPathA(NULL, CSIDL_LOCAL_APPDATA, NULL, 0, appDataPath);
|
||||||
sk = R"(SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders)";
|
if (SUCCEEDED(result)) {
|
||||||
openRes = RegOpenKeyEx(HKEY_CURRENT_USER, sk, 0, KEY_ALL_ACCESS, &hKey);
|
Path = appDataPath;
|
||||||
}
|
}
|
||||||
if (openRes != ERROR_SUCCESS) {
|
|
||||||
|
if (Path.empty()) {
|
||||||
fatal("Cannot get Local Appdata directory");
|
fatal("Cannot get Local Appdata directory");
|
||||||
}
|
}
|
||||||
|
|
||||||
Path = QueryKey(hKey, 5);
|
|
||||||
Path += "\\BeamNG.drive\\";
|
Path += "\\BeamNG.drive\\";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user