source: Daodan/MSYS2/mingw32/i686-w64-mingw32/include/versionhelpers.h@ 1166

Last change on this file since 1166 was 1166, checked in by rossy, 3 years ago

Daodan: Replace MinGW build env with an up-to-date MSYS2 env

File size: 2.9 KB
Line 
1/**
2 * This file is part of the mingw-w64 runtime package.
3 * No warranty is given; refer to the file DISCLAIMER within this package.
4 */
5
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
19VERSIONHELPERAPI IsWindowsVersionOrGreater(WORD major, WORD minor, WORD servpack)
20{
21 OSVERSIONINFOEXW vi = {sizeof(vi),major,minor,0,0,{0},servpack};
22 return VerifyVersionInfoW(&vi, VER_MAJORVERSION|VER_MINORVERSION|VER_SERVICEPACKMAJOR,
23 VerSetConditionMask(VerSetConditionMask(VerSetConditionMask(0,
24 VER_MAJORVERSION,VER_GREATER_EQUAL),
25 VER_MINORVERSION,VER_GREATER_EQUAL),
26 VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL));
27}
28
29VERSIONHELPERAPI IsWindowsXPOrGreater(void) {
30 return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WINXP), LOBYTE(_WIN32_WINNT_WINXP), 0);
31}
32
33VERSIONHELPERAPI IsWindowsXPSP1OrGreater(void) {
34 return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WINXP), LOBYTE(_WIN32_WINNT_WINXP), 1);
35}
36
37VERSIONHELPERAPI IsWindowsXPSP2OrGreater(void) {
38 return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WINXP), LOBYTE(_WIN32_WINNT_WINXP), 2);
39}
40
41VERSIONHELPERAPI IsWindowsXPSP3OrGreater(void) {
42 return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WINXP), LOBYTE(_WIN32_WINNT_WINXP), 3);
43}
44
45VERSIONHELPERAPI IsWindowsVistaOrGreater(void) {
46 return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_VISTA), LOBYTE(_WIN32_WINNT_VISTA), 0);
47}
48
49VERSIONHELPERAPI IsWindowsVistaSP1OrGreater(void) {
50 return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_VISTA), LOBYTE(_WIN32_WINNT_VISTA), 1);
51}
52
53VERSIONHELPERAPI IsWindowsVistaSP2OrGreater(void) {
54 return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_VISTA), LOBYTE(_WIN32_WINNT_VISTA), 2);
55}
56
57VERSIONHELPERAPI IsWindows7OrGreater(void) {
58 return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WIN7), LOBYTE(_WIN32_WINNT_WIN7), 0);
59}
60
61VERSIONHELPERAPI IsWindows7SP1OrGreater(void) {
62 return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WIN7), LOBYTE(_WIN32_WINNT_WIN7), 1);
63}
64
65VERSIONHELPERAPI IsWindows8OrGreater(void) {
66 return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WIN8), LOBYTE(_WIN32_WINNT_WIN8), 0);
67}
68
69VERSIONHELPERAPI IsWindows8Point1OrGreater(void) {
70 return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WINBLUE), LOBYTE(_WIN32_WINNT_WINBLUE), 0);
71}
72
73VERSIONHELPERAPI IsWindowsThresholdOrGreater(void) {
74 return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WINTHRESHOLD), LOBYTE(_WIN32_WINNT_WINTHRESHOLD), 0);
75}
76
77VERSIONHELPERAPI IsWindows10OrGreater(void) {
78 return IsWindowsThresholdOrGreater();
79}
80
81VERSIONHELPERAPI IsWindowsServer(void) {
82 OSVERSIONINFOEXW vi = {sizeof(vi),0,0,0,0,{0},0,0,0,VER_NT_WORKSTATION};
83 return !VerifyVersionInfoW(&vi, VER_PRODUCT_TYPE, VerSetConditionMask(0, VER_PRODUCT_TYPE, VER_EQUAL));
84}
85
86#endif
87#endif
Note: See TracBrowser for help on using the repository browser.