From 52055f62bc6a6297b8cdb5ee708a2d170d45d5e0 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 24 Oct 2013 15:05:34 +0200 Subject: Introduce Windows version 8.1 and detect by checking the version. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I04012218c34f7a95a87fcf2dc7fc095f0e743e67 Reviewed-by: Joerg Bornemann Reviewed-by: Oliver Wolff Reviewed-by: Andrew Knight Reviewed-by: Björn Breitmeyer (cherry picked from qtbase/dff6d73d6c37c40790d90bfdf3cb2f6e75c5bfa4) --- src/corelib/global/qglobal.cpp | 40 +++++++++++++++++++++++++++++++++++++--- src/corelib/global/qglobal.h | 2 ++ 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index b165575..facc7ab 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -1135,6 +1135,8 @@ bool qSharedBuild() \value WV_2003 Windows Server 2003, Windows Server 2003 R2, Windows Home Server, Windows XP Professional x64 Edition (operating system version 5.2) \value WV_VISTA Windows Vista, Windows Server 2008 (operating system version 6.0) \value WV_WINDOWS7 Windows 7, Windows Server 2008 R2 (operating system version 6.1) + \value WV_WINDOWS8 Windows 8 (operating system version 6.2) + \value WV_WINDOWS8_1 Windows 8.1 (operating system version 6.3), introduced in Qt 4.8.6 Alternatively, you may use the following macros which correspond directly to the Windows operating system version number: @@ -1144,6 +1146,8 @@ bool qSharedBuild() \value WV_5_2 Operating system version 5.2, corresponds to Windows Server 2003, Windows Server 2003 R2, Windows Home Server, and Windows XP Professional x64 Edition \value WV_6_0 Operating system version 6.0, corresponds to Windows Vista and Windows Server 2008 \value WV_6_1 Operating system version 6.1, corresponds to Windows 7 and Windows Server 2008 R2 + \value WV_6_2 Operating system version 6.2, corresponds to Windows 8 + \value WV_6_3 Operating system version 6.3, corresponds to Windows 8.1, introduced in Qt 4.8.6 CE-based versions: @@ -1684,6 +1688,36 @@ QT_BEGIN_INCLUDE_NAMESPACE #include "qt_windows.h" QT_END_INCLUDE_NAMESPACE +static inline OSVERSIONINFO winOsVersion() +{ + OSVERSIONINFO result = { sizeof(OSVERSIONINFO), 0, 0, 0, 0, {'\0'}}; + // GetVersionEx() has been deprecated in Windows 8.1 and will return + // only Windows 8 from that version on. +# if defined(_MSC_VER) && _MSC_VER >= 1800 +# pragma warning( push ) +# pragma warning( disable : 4996 ) +# endif + GetVersionEx(&result); +# if defined(_MSC_VER) && _MSC_VER >= 1800 +# pragma warning( pop ) +# endif +# ifndef Q_OS_WINCE + if (result.dwMajorVersion == 6 && result.dwMinorVersion == 2) { + // This could be Windows 8.1 or higher. Note that as of Windows 9, + // the major version needs to be checked as well. + DWORDLONG conditionMask = 0; + VER_SET_CONDITION(conditionMask, VER_MAJORVERSION, VER_GREATER_EQUAL); + VER_SET_CONDITION(conditionMask, VER_MINORVERSION, VER_GREATER_EQUAL); + VER_SET_CONDITION(conditionMask, VER_PLATFORMID, VER_EQUAL); + OSVERSIONINFOEX checkVersion = { sizeof(OSVERSIONINFOEX), result.dwMajorVersion, result.dwMinorVersion, + result.dwBuildNumber, result.dwPlatformId, {'\0'}, 0, 0, 0, 0, 0 }; + for ( ; VerifyVersionInfo(&checkVersion, VER_MAJORVERSION | VER_MINORVERSION | VER_PLATFORMID, conditionMask); ++checkVersion.dwMinorVersion) + result.dwMinorVersion = checkVersion.dwMinorVersion; + } +# endif // !Q_OS_WINCE + return result; +} + QSysInfo::WinVersion QSysInfo::windowsVersion() { #ifndef VER_PLATFORM_WIN32s @@ -1703,9 +1737,7 @@ QSysInfo::WinVersion QSysInfo::windowsVersion() if (winver) return winver; winver = QSysInfo::WV_NT; - OSVERSIONINFO osver; - osver.dwOSVersionInfoSize = sizeof(osver); - GetVersionEx(&osver); + const OSVERSIONINFO osver = winOsVersion(); #ifdef Q_OS_WINCE DWORD qt_cever = 0; qt_cever = osver.dwMajorVersion * 100; @@ -1751,6 +1783,8 @@ QSysInfo::WinVersion QSysInfo::windowsVersion() winver = QSysInfo::WV_WINDOWS7; } else if (osver.dwMajorVersion == 6 && osver.dwMinorVersion == 2) { winver = QSysInfo::WV_WINDOWS8; + } else if (osver.dwMajorVersion == 6 && osver.dwMinorVersion == 3) { + winver = QSysInfo::WV_WINDOWS8_1; } else { qWarning("Qt: Untested Windows version %d.%d detected!", int(osver.dwMajorVersion), int(osver.dwMinorVersion)); diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 6de28b6..dc1f477 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -1591,6 +1591,7 @@ public: WV_VISTA = 0x0080, WV_WINDOWS7 = 0x0090, WV_WINDOWS8 = 0x00a0, + WV_WINDOWS8_1 = 0x00b0, WV_NT_based = 0x00f0, /* version numbers */ @@ -1601,6 +1602,7 @@ public: WV_6_0 = WV_VISTA, WV_6_1 = WV_WINDOWS7, WV_6_2 = WV_WINDOWS8, + WV_6_3 = WV_WINDOWS8_1, WV_CE = 0x0100, WV_CENET = 0x0200, -- cgit v0.12