mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-21 03:26:01 +00:00
Replace deprecated GetVersionEx Win32 call
This commit is contained in:
@@ -116,31 +116,51 @@ SystemStats::CPUFlags::CPUFlags()
|
|||||||
}
|
}
|
||||||
|
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
|
static bool isWindowsVersionOrLater (SystemStats::OperatingSystemType target)
|
||||||
|
{
|
||||||
|
OSVERSIONINFOEX info;
|
||||||
|
zerostruct (info);
|
||||||
|
info.dwOSVersionInfoSize = sizeof (OSVERSIONINFOEX);
|
||||||
|
|
||||||
|
if (target >= SystemStats::WinVista)
|
||||||
|
{
|
||||||
|
info.dwMajorVersion = 6;
|
||||||
|
|
||||||
|
switch (target)
|
||||||
|
{
|
||||||
|
case SystemStats::WinVista: info.dwMinorVersion = 0; break;
|
||||||
|
case SystemStats::Windows7: info.dwMinorVersion = 1; break;
|
||||||
|
case SystemStats::Windows8: info.dwMinorVersion = 2; break;
|
||||||
|
default: bassertfalse; break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
info.dwMajorVersion = 5;
|
||||||
|
info.dwMinorVersion = target >= SystemStats::WinXP ? 1 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
DWORDLONG mask = 0;
|
||||||
|
|
||||||
|
VER_SET_CONDITION (mask, VER_MAJORVERSION, VER_GREATER_EQUAL);
|
||||||
|
VER_SET_CONDITION (mask, VER_MINORVERSION, VER_GREATER_EQUAL);
|
||||||
|
VER_SET_CONDITION (mask, VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL);
|
||||||
|
VER_SET_CONDITION (mask, VER_SERVICEPACKMINOR, VER_GREATER_EQUAL);
|
||||||
|
|
||||||
|
return VerifyVersionInfo (&info,
|
||||||
|
VER_MAJORVERSION | VER_MINORVERSION
|
||||||
|
| VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
|
||||||
|
mask) != FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
SystemStats::OperatingSystemType SystemStats::getOperatingSystemType()
|
SystemStats::OperatingSystemType SystemStats::getOperatingSystemType()
|
||||||
{
|
{
|
||||||
OSVERSIONINFO info;
|
const SystemStats::OperatingSystemType types[]
|
||||||
info.dwOSVersionInfoSize = sizeof (info);
|
= { Windows8, Windows7, WinVista, WinXP, Win2000 };
|
||||||
GetVersionEx (&info);
|
|
||||||
|
|
||||||
if (info.dwPlatformId == VER_PLATFORM_WIN32_NT)
|
for (int i = 0; i < numElementsInArray (types); ++i)
|
||||||
{
|
if (isWindowsVersionOrLater (types[i]))
|
||||||
if (info.dwMajorVersion == 5)
|
return types[i];
|
||||||
return (info.dwMinorVersion == 0) ? Win2000 : WinXP;
|
|
||||||
|
|
||||||
if (info.dwMajorVersion == 6)
|
|
||||||
{
|
|
||||||
switch (info.dwMinorVersion)
|
|
||||||
{
|
|
||||||
case 0: return WinVista;
|
|
||||||
case 1: return Windows7;
|
|
||||||
case 2: return Windows8;
|
|
||||||
|
|
||||||
default:
|
|
||||||
bassertfalse; // new version needs to be added here!
|
|
||||||
return Windows8;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bassertfalse; // need to support whatever new version is running!
|
bassertfalse; // need to support whatever new version is running!
|
||||||
return UnknownOS;
|
return UnknownOS;
|
||||||
|
|||||||
Reference in New Issue
Block a user