ReactOS  0.4.15-dev-341-g17c5fb8
versionhelpers.h
Go to the documentation of this file.
1 /*
2  * versionhelpers.h
3  *
4  * Inline helper functions for Windows version detection
5  *
6  * This file is part of the ReactOS PSDK package.
7  *
8  * Contributors:
9  * Created by Timo Kreuzer <timo.kreuzer@reactos.org>
10  *
11  * THIS SOFTWARE IS NOT COPYRIGHTED
12  *
13  * This source code is offered for use in the public domain. You may
14  * use, modify or distribute it freely.
15  *
16  * This code is distributed in the hope that it will be useful but
17  * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
18  * DISCLAMED. This includes but is not limited to warranties of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
20  *
21  */
22 
23 #pragma once
24 #define _versionhelpers_H_INCLUDED_
25 
26 #include <specstrings.h>
27 
28 #ifdef __cplusplus
29 #define VERSIONHELPERAPI inline bool
30 #else
31 #define VERSIONHELPERAPI FORCEINLINE BOOL
32 #endif
33 
35 IsWindowsVersionOrGreater(WORD wMajorVersion, WORD wMinorVersion, WORD wServicePackMajor)
36 {
37  OSVERSIONINFOEXW osvi = { sizeof(osvi), wMajorVersion, wMinorVersion, 0, 0, {0}, wServicePackMajor, 0, 0, 0, 0 };
39  dwlConditionMask = VerSetConditionMask(dwlConditionMask, VER_MINORVERSION, VER_GREATER_EQUAL);
40  dwlConditionMask = VerSetConditionMask(dwlConditionMask, VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL);
41 
43 }
44 
47 {
48  return IsWindowsVersionOrGreater(5, 1, 0);
49 }
50 
53 {
54  return IsWindowsVersionOrGreater(5, 1, 1);
55 }
56 
59 {
60  return IsWindowsVersionOrGreater(5, 1, 2);
61 }
62 
65 {
66  return IsWindowsVersionOrGreater(5, 1, 3);
67 }
68 
71 {
72  return IsWindowsVersionOrGreater(6, 0, 0);
73 }
74 
77 {
78  return IsWindowsVersionOrGreater(6, 0, 1);
79 }
80 
83 {
84  return IsWindowsVersionOrGreater(6, 0, 2);
85 }
86 
89 {
90  return IsWindowsVersionOrGreater(6, 1, 0);
91 }
92 
95 {
96  return IsWindowsVersionOrGreater(6, 1, 1);
97 }
98 
101 {
102  return IsWindowsVersionOrGreater(6, 2, 0);
103 }
104 
107 {
108  return IsWindowsVersionOrGreater(6, 3, 0);
109 }
110 
113 {
114  return IsWindowsVersionOrGreater(10, 0, 0);
115 }
116 
119 {
120  return IsWindowsVersionOrGreater(10, 0, 0);
121 }
122 
125 {
126  OSVERSIONINFOEXW osvi = { sizeof(osvi), 0, 0, 0, 0, {0}, 0, 0, 0, VER_NT_WORKSTATION };
127  DWORDLONG const dwlConditionMask = VerSetConditionMask(0, VER_PRODUCT_TYPE, VER_EQUAL);
128  return VerifyVersionInfoW(&osvi, VER_PRODUCT_TYPE, dwlConditionMask) == FALSE;
129 }
130 
133 {
134  OSVERSIONINFOEXW osvi = { sizeof(osvi), 0, 0, 0, 0, {0}, 0, 0, 0, 0, 0 };
135  DWORDLONG dwlConditionMask = VerSetConditionMask(0, VER_SUITENAME, VER_AND);
136  BOOL fSuiteTerminal, fSuiteSingleUserTS;
137 
138  osvi.wSuiteMask = VER_SUITE_TERMINAL;
139  fSuiteTerminal = VerifyVersionInfoW(&osvi, VER_SUITENAME, dwlConditionMask);
140 
141  osvi.wSuiteMask = VER_SUITE_SINGLEUSERTS;
142  fSuiteSingleUserTS = VerifyVersionInfoW(&osvi, VER_SUITENAME, dwlConditionMask);
143 
144  return !(fSuiteTerminal & !fSuiteSingleUserTS);
145 }
146 
147 #ifdef __REACTOS__
149 IsReactOS()
150 {
151  // FIXME: Find a better method!
152  WCHAR szWinDir[MAX_PATH];
153  GetWindowsDirectoryW(szWinDir, _countof(szWinDir));
154  return (wcsstr(szWinDir, L"ReactOS") != NULL);
155 }
156 #endif // __REACTOS__
#define VER_MINORVERSION
Definition: rtltypes.h:226
#define VER_NT_WORKSTATION
VERSIONHELPERAPI IsWindows8Point1OrGreater()
#define VER_SUITENAME
Definition: rtltypes.h:232
#define VER_AND
Definition: rtltypes.h:242
ULONGLONG NTAPI VerSetConditionMask(IN ULONGLONG ConditionMask, IN ULONG TypeMask, IN UCHAR Condition)
Definition: version.c:262
OSVERSIONINFO osvi
Definition: ver.c:28
VERSIONHELPERAPI IsWindowsXPSP3OrGreater()
VERSIONHELPERAPI IsWindowsXPSP1OrGreater()
_CONST_RETURN wchar_t *__cdecl wcsstr(_In_z_ const wchar_t *_Str, _In_z_ const wchar_t *_SubStr)
VERSIONHELPERAPI IsWindowsVistaSP2OrGreater()
VERSIONHELPERAPI IsWindowsVistaSP1OrGreater()
#define VER_SUITE_TERMINAL
UINT WINAPI GetWindowsDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2351
VERSIONHELPERAPI IsWindowsThresholdOrGreater()
#define VER_PRODUCT_TYPE
Definition: rtltypes.h:233
unsigned int BOOL
Definition: ntddk_ex.h:94
VERSIONHELPERAPI IsWindows7SP1OrGreater()
VERSIONHELPERAPI IsWindows10OrGreater()
smooth NULL
Definition: ftsmooth.c:416
VERSIONHELPERAPI IsWindowsVistaOrGreater()
BOOL WINAPI VerifyVersionInfoW(IN LPOSVERSIONINFOEXW lpVersionInformation, IN DWORD dwTypeMask, IN DWORDLONG dwlConditionMask)
Definition: version.c:118
#define VER_EQUAL
Definition: rtltypes.h:237
__wchar_t WCHAR
Definition: xmlstorage.h:180
VERSIONHELPERAPI IsWindowsXPOrGreater()
#define _countof(array)
Definition: sndvol32.h:68
VERSIONHELPERAPI IsWindows8OrGreater()
#define MAX_PATH
Definition: compat.h:26
#define VER_MAJORVERSION
Definition: rtltypes.h:227
unsigned short WORD
Definition: ntddk_ex.h:93
VERSIONHELPERAPI IsWindowsServer()
VERSIONHELPERAPI IsWindowsVersionOrGreater(WORD wMajorVersion, WORD wMinorVersion, WORD wServicePackMajor)
#define VER_SERVICEPACKMAJOR
Definition: rtltypes.h:231
static const WCHAR L[]
Definition: oid.c:1250
#define VERSIONHELPERAPI
#define VER_GREATER_EQUAL
Definition: rtltypes.h:239
#define VER_SUITE_SINGLEUSERTS
VERSIONHELPERAPI IsWindowsXPSP2OrGreater()
VERSIONHELPERAPI IsWindows7OrGreater()
unsigned long long DWORDLONG
Definition: intsafe.h:99
VERSIONHELPERAPI IsActiveSessionCountLimited()