--- /dev/null
+// Clean drop-in replacement for the versionhelpers.h header\r
+//\r
+// Copyright (C) 2015 Alessandro Menti <alessandro.menti@hotmail.it>\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Library General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2 of the License, or (at your option) any later version.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Library General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Library General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA\r
+\r
+#ifndef SG_VERSIONHELPERS_HXX_\r
+#define SG_VERSIONHELPERS_HXX_\r
+\r
+#include <sdkddkver.h>\r
+\r
+#ifdef __cplusplus\r
+#define VERSIONHELPERAPI inline bool\r
+#else\r
+#define VERSIONHELPERAPI FORCEINLINE BOOL\r
+#endif // __cplusplus\r
+\r
+/* Windows 8/8.1 version numbers, not defined in the Windows 7 SDK. */\r
+#ifndef _WIN32_WINNT_WIN8\r
+#define _WIN32_WINNT_WIN8 0x0602\r
+#endif\r
+#ifndef _WIN32_WINNT_WINBLUE\r
+#define _WIN32_WINNT_WINBLUE 0x0603\r
+#endif\r
+\r
+VERSIONHELPERAPI IsWindowsVersionOrGreater(WORD wMajorVersion,\r
+ WORD wMinorVersion, WORD wServicePackMajor) {\r
+ OSVERSIONINFOEXW osVersionInfo;\r
+ DWORDLONG dwlConditionMask = 0;\r
+ ZeroMemory(&osVersionInfo, sizeof(osVersionInfo));\r
+ osVersionInfo.dwOSVersionInfoSize = sizeof(osVersionInfo);\r
+ osVersionInfo.dwMajorVersion = wMajorVersion;\r
+ osVersionInfo.dwMinorVersion = wMinorVersion;\r
+ osVersionInfo.wServicePackMajor = wServicePackMajor;\r
+ VER_SET_CONDITION(dwlConditionMask, VER_MAJORVERSION,\r
+ VER_GREATER_EQUAL);\r
+ VER_SET_CONDITION(dwlConditionMask, VER_MINORVERSION,\r
+ VER_GREATER_EQUAL);\r
+ VER_SET_CONDITION(dwlConditionMask, VER_SERVICEPACKMAJOR,\r
+ VER_GREATER_EQUAL);\r
+ return VerifyVersionInfoW(&osVersionInfo, VER_MAJORVERSION\r
+ | VER_MINORVERSION | VER_SERVICEPACKMAJOR, dwlConditionMask);\r
+}\r
+\r
+VERSIONHELPERAPI IsWindowsXPOrGreater() {\r
+ return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WINXP),\r
+ LOBYTE(_WIN32_WINNT_WINXP), 0);\r
+}\r
+\r
+VERSIONHELPERAPI IsWindowsXPSP1OrGreater() {\r
+ return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WINXP),\r
+ LOBYTE(_WIN32_WINNT_WINXP), 1);\r
+}\r
+\r
+VERSIONHELPERAPI IsWindowsXPSP2OrGreater() {\r
+ return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WINXP),\r
+ LOBYTE(_WIN32_WINNT_WINXP), 2);\r
+}\r
+\r
+VERSIONHELPERAPI IsWindowsXPSP3OrGreater() {\r
+ return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WINXP),\r
+ LOBYTE(_WIN32_WINNT_WINXP), 3);\r
+}\r
+\r
+VERSIONHELPERAPI IsWindowsVistaOrGreater() {\r
+ return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_VISTA),\r
+ LOBYTE(_WIN32_WINNT_VISTA), 0);\r
+}\r
+\r
+VERSIONHELPERAPI IsWindowsVistaSP1OrGreater() {\r
+ return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_VISTA),\r
+ LOBYTE(_WIN32_WINNT_VISTA), 1);\r
+}\r
+\r
+VERSIONHELPERAPI IsWindowsVistaSP2OrGreater() {\r
+ return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_VISTA),\r
+ LOBYTE(_WIN32_WINNT_VISTA), 2);\r
+}\r
+\r
+VERSIONHELPERAPI IsWindows7OrGreater() {\r
+ return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WIN7),\r
+ LOBYTE(_WIN32_WINNT_WIN7), 0);\r
+}\r
+\r
+VERSIONHELPERAPI IsWindows7SP1OrGreater() {\r
+ return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WIN7),\r
+ LOBYTE(_WIN32_WINNT_WIN7), 1);\r
+}\r
+\r
+VERSIONHELPERAPI IsWindows8OrGreater() {\r
+ return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WIN8),\r
+ LOBYTE(_WIN32_WINNT_WIN8), 0);\r
+}\r
+\r
+VERSIONHELPERAPI IsWindows8Point1OrGreater() {\r
+ return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WINBLUE),\r
+ LOBYTE(_WIN32_WINNT_WINBLUE), 0);\r
+}\r
+\r
+VERSIONHELPERAPI IsWindowsServer() {\r
+ OSVERSIONINFOEXW osVersionInfo;\r
+ DWORDLONG dwlConditionMask = 0;\r
+ ZeroMemory(&osVersionInfo, sizeof(osVersionInfo));\r
+ osVersionInfo.dwOSVersionInfoSize = sizeof(osVersionInfo);\r
+ osVersionInfo.wProductType = VER_NT_WORKSTATION;\r
+ VER_SET_CONDITION(dwlConditionMask, VER_PRODUCT_TYPE, VER_EQUAL);\r
+ return !VerifyVersionInfoW(&osVersionInfo, VER_PRODUCT_TYPE,\r
+ dwlConditionMask);\r
+}\r
+#endif // SG_VERSIONHELPERS_HXX_\r