Browse Source

Replaced use of the deprecated GetVersionEx win32 call.

tags/2021-05-28
jules 12 years ago
parent
commit
93d7d79b95
1 changed files with 38 additions and 18 deletions
  1. +38
    -18
      modules/juce_core/native/juce_win32_SystemStats.cpp

+ 38
- 18
modules/juce_core/native/juce_win32_SystemStats.cpp View File

@@ -133,31 +133,51 @@ static DebugFlagsInitialiser debugFlagsInitialiser;
#endif
//==============================================================================
SystemStats::OperatingSystemType SystemStats::getOperatingSystemType()
static bool isWindowsVersionOrLater (SystemStats::OperatingSystemType target)
{
OSVERSIONINFO info;
info.dwOSVersionInfoSize = sizeof (info);
GetVersionEx (&info);
OSVERSIONINFOEX info;
zerostruct (info);
info.dwOSVersionInfoSize = sizeof (OSVERSIONINFOEX);
if (info.dwPlatformId == VER_PLATFORM_WIN32_NT)
if (target >= SystemStats::WinVista)
{
if (info.dwMajorVersion == 5)
return (info.dwMinorVersion == 0) ? Win2000 : WinXP;
info.dwMajorVersion = 6;
if (info.dwMajorVersion == 6)
switch (target)
{
switch (info.dwMinorVersion)
{
case 0: return WinVista;
case 1: return Windows7;
case 2: return Windows8;
default:
jassertfalse; // new version needs to be added here!
return Windows8;
}
case SystemStats::WinVista: info.dwMinorVersion = 0; break;
case SystemStats::Windows7: info.dwMinorVersion = 1; break;
case SystemStats::Windows8: info.dwMinorVersion = 2; break;
default: jassertfalse; 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()
{
const SystemStats::OperatingSystemType types[]
= { Windows8, Windows7, WinVista, WinXP, Win2000 };
for (int i = 0; i < numElementsInArray (types); ++i)
if (isWindowsVersionOrLater (types[i]))
return types[i];
jassertfalse; // need to support whatever new version is running!
return UnknownOS;


Loading…
Cancel
Save