mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-11-10 08:38:20 +00:00
[host] windows: read ProductName from registry if possible
For Windows 10, it so happens that the major.minor is 10.0. This is not usually a given, e.g. on Windows 7 where it would read 6.1, on Windows 8 it would read 6.2, and on Windows 8.1 it would read 6.3. This is obviously undesirable, so we should just read the ProductName from registry if possible. This results in something like: OS Name: Windows 10 Pro for Workstations (Build: 19043)
This commit is contained in:
parent
f247d7f0da
commit
e85fd68d82
@ -615,6 +615,21 @@ KVMFROS os_getKVMFRType(void)
|
||||
return KVMFR_OS_WINDOWS;
|
||||
}
|
||||
|
||||
static bool getProductName(char * buffer, DWORD bufferSize)
|
||||
{
|
||||
LSTATUS status = RegGetValueA(HKEY_LOCAL_MACHINE,
|
||||
"Software\\Microsoft\\Windows NT\\CurrentVersion", "ProductName",
|
||||
RRF_RT_REG_SZ, NULL, buffer, &bufferSize);
|
||||
|
||||
if (status != ERROR_SUCCESS)
|
||||
{
|
||||
DEBUG_WINERROR("Failed to read ProductName from registry", status);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
const char * os_getOSName(void)
|
||||
{
|
||||
if (app.osVersion)
|
||||
@ -624,14 +639,28 @@ const char * os_getOSName(void)
|
||||
osvi.dwOSVersionInfoSize = sizeof(osvi);
|
||||
GetVersionExA(&osvi);
|
||||
|
||||
alloc_sprintf(
|
||||
&app.osVersion,
|
||||
"Windows %lu.%lu (Build: %lu) %s",
|
||||
osvi.dwMajorVersion,
|
||||
osvi.dwMinorVersion,
|
||||
osvi.dwBuildNumber,
|
||||
osvi.szCSDVersion
|
||||
);
|
||||
char productName[1024];
|
||||
if (getProductName(productName, sizeof(productName)))
|
||||
{
|
||||
alloc_sprintf(
|
||||
&app.osVersion,
|
||||
"%s (Build: %lu) %s",
|
||||
productName,
|
||||
osvi.dwBuildNumber,
|
||||
osvi.szCSDVersion
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
alloc_sprintf(
|
||||
&app.osVersion,
|
||||
"Windows %lu.%lu (Build: %lu) %s",
|
||||
osvi.dwMajorVersion,
|
||||
osvi.dwMinorVersion,
|
||||
osvi.dwBuildNumber,
|
||||
osvi.szCSDVersion
|
||||
);
|
||||
}
|
||||
|
||||
return app.osVersion;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user