mirror of
https://github.com/cemu-project/Cemu.git
synced 2024-11-25 18:46:55 +01:00
Log Windows version + Fix logging crash on Linux
This commit is contained in:
parent
890df997cb
commit
892ae13680
@ -484,26 +484,53 @@ namespace CafeSystem
|
||||
#endif
|
||||
}
|
||||
|
||||
#if BOOST_OS_WINDOWS
|
||||
std::string GetWindowsNamedVersion(uint32& buildNumber)
|
||||
{
|
||||
static char productName[256];
|
||||
HKEY hKey;
|
||||
DWORD dwType = REG_SZ;
|
||||
DWORD dwSize = sizeof(productName);
|
||||
if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS)
|
||||
{
|
||||
if (RegQueryValueExA(hKey, "ProductName", NULL, &dwType, (LPBYTE)productName, &dwSize) != ERROR_SUCCESS)
|
||||
strcpy(productName, "Windows");
|
||||
RegCloseKey(hKey);
|
||||
}
|
||||
OSVERSIONINFO osvi;
|
||||
ZeroMemory(&osvi, sizeof(OSVERSIONINFO));
|
||||
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
|
||||
GetVersionEx(&osvi);
|
||||
buildNumber = osvi.dwBuildNumber;
|
||||
return std::string(productName);
|
||||
}
|
||||
#endif
|
||||
|
||||
void logPlatformInfo()
|
||||
{
|
||||
std::string buffer;
|
||||
const char* platform = NULL;
|
||||
#if BOOST_OS_WINDOWS
|
||||
platform = "Windows";
|
||||
uint32 buildNumber;
|
||||
std::string windowsVersionName = GetWindowsNamedVersion(buildNumber);
|
||||
buffer = fmt::format("{} (Build {})", windowsVersionName, buildNumber);
|
||||
platform = buffer.c_str();
|
||||
#elif BOOST_OS_LINUX
|
||||
if (getenv ("APPIMAGE"))
|
||||
platform = "Linux (AppImage)";
|
||||
else if (getenv ("SNAP"))
|
||||
platform = "Linux (Snap)";
|
||||
else if (platform = getenv ("container"))
|
||||
{
|
||||
if (strcmp (platform, "flatpak") == 0)
|
||||
platform = "Linux (Flatpak)";
|
||||
}
|
||||
else
|
||||
platform = "Linux";
|
||||
#elif BOOST_OS_MACOS
|
||||
platform = "MacOS";
|
||||
#endif
|
||||
cemuLog_log(LogType::Force, "Platform: {}", platform);
|
||||
|
||||
}
|
||||
|
||||
// initialize all subsystems which are persistent and don't depend on a game running
|
||||
|
Loading…
Reference in New Issue
Block a user