ReactOS 0.4.16-dev-306-g647d351
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
35IsWindowsVersionOrGreater(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__
149IsReactOS()
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 NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define MAX_PATH
Definition: compat.h:34
UINT WINAPI GetWindowsDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2352
BOOL WINAPI VerifyVersionInfoW(IN LPOSVERSIONINFOEXW lpVersionInformation, IN DWORD dwTypeMask, IN DWORDLONG dwlConditionMask)
Definition: version.c:118
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned short WORD
Definition: ntddk_ex.h:93
_CONST_RETURN wchar_t *__cdecl wcsstr(_In_z_ const wchar_t *_Str, _In_z_ const wchar_t *_SubStr)
unsigned long long DWORDLONG
Definition: intsafe.h:93
#define VER_AND
Definition: rtltypes.h:244
#define VER_SUITENAME
Definition: rtltypes.h:234
#define VER_EQUAL
Definition: rtltypes.h:239
#define VER_MAJORVERSION
Definition: rtltypes.h:229
#define VER_PRODUCT_TYPE
Definition: rtltypes.h:235
#define VER_GREATER_EQUAL
Definition: rtltypes.h:241
#define VER_MINORVERSION
Definition: rtltypes.h:228
#define VER_SERVICEPACKMAJOR
Definition: rtltypes.h:233
#define VER_SUITE_TERMINAL
#define VER_SUITE_SINGLEUSERTS
#define L(x)
Definition: ntvdm.h:50
ULONGLONG NTAPI VerSetConditionMask(IN ULONGLONG ConditionMask, IN ULONG TypeMask, IN UCHAR Condition)
Definition: version.c:262
#define _countof(array)
Definition: sndvol32.h:70
OSVERSIONINFO osvi
Definition: ver.c:28
VERSIONHELPERAPI IsWindows7OrGreater()
VERSIONHELPERAPI IsWindowsVistaOrGreater()
VERSIONHELPERAPI IsWindows8OrGreater()
VERSIONHELPERAPI IsWindowsVersionOrGreater(WORD wMajorVersion, WORD wMinorVersion, WORD wServicePackMajor)
VERSIONHELPERAPI IsWindowsXPSP3OrGreater()
VERSIONHELPERAPI IsWindowsVistaSP2OrGreater()
VERSIONHELPERAPI IsActiveSessionCountLimited()
VERSIONHELPERAPI IsWindowsServer()
VERSIONHELPERAPI IsWindowsXPSP1OrGreater()
VERSIONHELPERAPI IsWindows10OrGreater()
#define VERSIONHELPERAPI
VERSIONHELPERAPI IsWindows7SP1OrGreater()
VERSIONHELPERAPI IsWindowsThresholdOrGreater()
VERSIONHELPERAPI IsWindowsXPSP2OrGreater()
VERSIONHELPERAPI IsWindowsVistaSP1OrGreater()
VERSIONHELPERAPI IsWindows8Point1OrGreater()
VERSIONHELPERAPI IsWindowsXPOrGreater()
#define VER_NT_WORKSTATION
__wchar_t WCHAR
Definition: xmlstorage.h:180