1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_WindowsVersion_h
8 #define mozilla_WindowsVersion_h
10 #include "mozilla/Attributes.h"
17 IsWindowsVersionOrLater(uint32_t aVersion
)
19 static uint32_t minVersion
= 0;
20 static uint32_t maxVersion
= UINT32_MAX
;
22 if (minVersion
>= aVersion
) {
26 if (aVersion
>= maxVersion
) {
31 ZeroMemory(&info
, sizeof(OSVERSIONINFOEX
));
32 info
.dwOSVersionInfoSize
= sizeof(OSVERSIONINFOEX
);
33 info
.dwMajorVersion
= aVersion
>> 24;
34 info
.dwMinorVersion
= (aVersion
>> 16) & 0xFF;
35 info
.wServicePackMajor
= (aVersion
>> 8) & 0xFF;
36 info
.wServicePackMinor
= aVersion
& 0xFF;
38 DWORDLONG conditionMask
= 0;
39 VER_SET_CONDITION(conditionMask
, VER_MAJORVERSION
, VER_GREATER_EQUAL
);
40 VER_SET_CONDITION(conditionMask
, VER_MINORVERSION
, VER_GREATER_EQUAL
);
41 VER_SET_CONDITION(conditionMask
, VER_SERVICEPACKMAJOR
, VER_GREATER_EQUAL
);
42 VER_SET_CONDITION(conditionMask
, VER_SERVICEPACKMINOR
, VER_GREATER_EQUAL
);
44 if (VerifyVersionInfo(&info
,
45 VER_MAJORVERSION
| VER_MINORVERSION
|
46 VER_SERVICEPACKMAJOR
| VER_SERVICEPACKMINOR
,
48 minVersion
= aVersion
;
52 maxVersion
= aVersion
;
57 IsWindowsBuildOrLater(uint32_t aBuild
)
59 static uint32_t minBuild
= 0;
60 static uint32_t maxBuild
= UINT32_MAX
;
62 if (minBuild
>= aBuild
) {
66 if (aBuild
>= maxBuild
) {
71 ZeroMemory(&info
, sizeof(OSVERSIONINFOEX
));
72 info
.dwOSVersionInfoSize
= sizeof(OSVERSIONINFOEX
);
73 info
.dwBuildNumber
= aBuild
;
75 DWORDLONG conditionMask
= 0;
76 VER_SET_CONDITION(conditionMask
, VER_BUILDNUMBER
, VER_GREATER_EQUAL
);
78 if (VerifyVersionInfo(&info
, VER_BUILDNUMBER
, conditionMask
)) {
87 MOZ_ALWAYS_INLINE
bool
90 return IsWindowsVersionOrLater(0x05010300ul
);
93 MOZ_ALWAYS_INLINE
bool
96 return IsWindowsVersionOrLater(0x05020000ul
);
99 MOZ_ALWAYS_INLINE
bool
100 IsWin2003SP2OrLater()
102 return IsWindowsVersionOrLater(0x05020200ul
);
105 MOZ_ALWAYS_INLINE
bool
108 return IsWindowsVersionOrLater(0x06000000ul
);
111 MOZ_ALWAYS_INLINE
bool
114 return IsWindowsVersionOrLater(0x06000100ul
);
117 MOZ_ALWAYS_INLINE
bool
120 return IsWindowsVersionOrLater(0x06010000ul
);
123 MOZ_ALWAYS_INLINE
bool
126 return IsWindowsVersionOrLater(0x06010100ul
);
129 MOZ_ALWAYS_INLINE
bool
132 return IsWindowsVersionOrLater(0x06020000ul
);
135 MOZ_ALWAYS_INLINE
bool
138 return IsWin7SP1OrLater() || !IsWin7OrLater() ||
139 IsWindowsBuildOrLater(7600);
142 } // namespace mozilla
144 #endif /* mozilla_WindowsVersion_h */