OpenVPN
compat-versionhelpers.h
Go to the documentation of this file.
1 
6 #ifndef _INC_VERSIONHELPERS
7 #define _INC_VERSIONHELPERS
8 
9 #include <winapifamily.h>
10 
11 #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) && !defined(__WIDL__)
12 
13 #ifdef __cplusplus
14 #define VERSIONHELPERAPI inline bool
15 #else
16 #define VERSIONHELPERAPI FORCEINLINE BOOL
17 #endif
18 
19 #define _WIN32_WINNT_WINBLUE 0x0603
20 
21 VERSIONHELPERAPI
22 IsWindowsVersionOrGreater(WORD major, WORD minor, WORD servpack)
23 {
24  OSVERSIONINFOEXW vi = {sizeof(vi),major,minor,0,0,{0},servpack};
25  return VerifyVersionInfoW(&vi, VER_MAJORVERSION|VER_MINORVERSION|VER_SERVICEPACKMAJOR,
26  VerSetConditionMask(VerSetConditionMask(VerSetConditionMask(0,
27  VER_MAJORVERSION,VER_GREATER_EQUAL),
28  VER_MINORVERSION,VER_GREATER_EQUAL),
29  VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL));
30 }
31 
32 VERSIONHELPERAPI
33 IsWindowsXPOrGreater(void)
34 {
35  return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WINXP), LOBYTE(_WIN32_WINNT_WINXP), 0);
36 }
37 
38 VERSIONHELPERAPI
39 IsWindowsXPSP1OrGreater(void)
40 {
41  return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WINXP), LOBYTE(_WIN32_WINNT_WINXP), 1);
42 }
43 
44 VERSIONHELPERAPI
45 IsWindowsXPSP2OrGreater(void)
46 {
47  return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WINXP), LOBYTE(_WIN32_WINNT_WINXP), 2);
48 }
49 
50 VERSIONHELPERAPI
51 IsWindowsXPSP3OrGreater(void)
52 {
53  return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WINXP), LOBYTE(_WIN32_WINNT_WINXP), 3);
54 }
55 
56 VERSIONHELPERAPI
57 IsWindowsVistaOrGreater(void)
58 {
59  return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_VISTA), LOBYTE(_WIN32_WINNT_VISTA), 0);
60 }
61 
62 VERSIONHELPERAPI
63 IsWindowsVistaSP1OrGreater(void)
64 {
65  return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_VISTA), LOBYTE(_WIN32_WINNT_VISTA), 1);
66 }
67 
68 VERSIONHELPERAPI
69 IsWindowsVistaSP2OrGreater(void)
70 {
71  return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_VISTA), LOBYTE(_WIN32_WINNT_VISTA), 2);
72 }
73 
74 VERSIONHELPERAPI
75 IsWindows7OrGreater(void)
76 {
77  return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WIN7), LOBYTE(_WIN32_WINNT_WIN7), 0);
78 }
79 
80 VERSIONHELPERAPI
81 IsWindows7SP1OrGreater(void)
82 {
83  return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WIN7), LOBYTE(_WIN32_WINNT_WIN7), 1);
84 }
85 
86 VERSIONHELPERAPI
87 IsWindows8OrGreater(void)
88 {
89  return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WIN8), LOBYTE(_WIN32_WINNT_WIN8), 0);
90 }
91 
92 VERSIONHELPERAPI
93 IsWindows8Point1OrGreater(void)
94 {
95  return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WINBLUE), LOBYTE(_WIN32_WINNT_WINBLUE), 0);
96 }
97 
98 VERSIONHELPERAPI
99 IsWindowsServer(void)
100 {
101  OSVERSIONINFOEXW vi = {sizeof(vi),0,0,0,0,{0},0,0,0,VER_NT_WORKSTATION};
102  return !VerifyVersionInfoW(&vi, VER_PRODUCT_TYPE, VerSetConditionMask(0, VER_PRODUCT_TYPE, VER_EQUAL));
103 }
104 
105 #endif /* if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) && !defined(__WIDL__) */
106 #endif /* ifndef _INC_VERSIONHELPERS */