Add wxCheckOsVersion() to implement platform based OS version checks.
Windows implements VerifyVersionInfo api since Win2k. Starting with Windows 8.1 GetVersionEx is deprecated and may not return the expected version number if the application does not contain the correct compatibility information in its manifest. VerifyVersionInfo works independent of manifest in the executable (and is the recommend way to check). Existing code may already use wxPlatformInfo::CheckOSVersion() so the method forwards the call to wxCheckOsVersion if initialized for the current system.
This commit is contained in:
@@ -1327,6 +1327,21 @@ wxOperatingSystemId wxGetOsVersion(int *verMaj, int *verMin)
|
||||
return s_version.os;
|
||||
}
|
||||
|
||||
bool wxCheckOsVersion(int majorVsn, int minorVsn)
|
||||
{
|
||||
OSVERSIONINFOEX osvi = { sizeof(osvi), 0, 0, 0, 0, { 0 }, 0, 0 };
|
||||
DWORDLONG const dwlConditionMask =
|
||||
::VerSetConditionMask(
|
||||
::VerSetConditionMask(
|
||||
0, VER_MAJORVERSION, VER_GREATER_EQUAL),
|
||||
VER_MINORVERSION, VER_GREATER_EQUAL);
|
||||
|
||||
osvi.dwMajorVersion = majorVsn;
|
||||
osvi.dwMinorVersion = minorVsn;
|
||||
|
||||
return ::VerifyVersionInfo(&osvi, VER_MAJORVERSION | VER_MINORVERSION, dwlConditionMask) != FALSE;
|
||||
}
|
||||
|
||||
wxWinVersion wxGetWinVersion()
|
||||
{
|
||||
int verMaj,
|
||||
|
Reference in New Issue
Block a user