Windows Version Verification
BOOL IsWin7OrLater() { // Initialization. OSVERSIONINFOEX osVerInfo = {}; osVerInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); osVerInfo.dwMajorVersion = 6; osVerInfo.dwMinorVersion = 1; // Set condition. DWORDLONG conditionMask = 0; int op = VER_GREATER_EQUAL; VER_SET_CONDITION(conditionMask, VER_MAJORVERSION, op); VER_SET_CONDITION(conditionMask, VER_MINORVERSION, op); // Verification. return VerifyVersionInfo(&osVerInfo, VER_MAJORVERSION | VER_MINORVERSION , conditionMask); }
Operating system | Version number |
---|---|
Windows 7 | 6.1 |
Windows Server 2008 R2 | 6.1 |
Windows Server 2008 | 6.0 |
Windows Vista | 6.0 |
Windows Server 2003 R2 | 5.2 |
Windows Server 2003 | 5.2 |
Windows XP 64-Bit Edition | 5.2 |
Windows XP | 5.1 |
Windows 2000 | 5.0 |
http://msdn.microsoft.com/en-us/library/windows/desktop/ms724832(v=vs.85).aspx