-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApiCheck.h
149 lines (107 loc) · 4.41 KB
/
ApiCheck.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#pragma once
#include "ApiCheckCore.h"
/**
ApiCheck
These functions help you efficiently determine if a particular WinRT API is present.
They can be used from pure C++, C++/CX, or C++/WinRT, and work on any Windows 10 version or later (but not Windows 8).
ApiCheck.h includes higher-level helper functions for common Windows versions and APIs.
ApiCheckCore.h includes lower-level helper functions for checking for custom APIs that don't have a higher-level helper function.
--------------------------------------------------
Example usage:
Is this running on Windows RS5 or later?
bool isRS5 = ApiCheck::IsAtLeastRS5();
-OR-
bool isRS5 = ApiCheck::IsAtLeast<ApiCheck::WindowsVersion::RS5>();
Does this version of Windows include RevealBrush, which was introduced in RS3?
bool isRevealSupported = ApiCheck::IsRevealBrushAvailable();
-OR-
bool isRevealSupported = ApiCheck::IsTypePresent<RuntimeClass_Windows_UI_Xaml_Media_RevealBrush, ApiCheck::WindowsVersion::RS3>();
Does this version of Windows include a version of the RevealBrush type with a property named "FakeProperty"?
extern const wchar_t FakeProperty[] = L"FakeProperty";
bool isFakePropertySupported = ApiCheck::IsPropertyPresent<RuntimeClass_Windows_UI_Xaml_Media_RevealBrush, FakeProperty, ApiCheck::WindowsVersion::None>();
Examples of all of those are present below.
*/
namespace ApiCheck {
// ------------------------------------------------------------
// Direct Windows OS version checks
// ------------------------------------------------------------
/**
Returns true if the app is running on Windows RS1 or a later version.
The result is cached, so checking the version a second time is extremely fast.
*/
static inline bool IsAtLeastRS1() noexcept
{
return ApiCheck::IsAtLeast<ApiCheck::WindowsVersion::RS1>();
}
/**
Returns true if the app is running on Windows RS2 or a later version.
The result is cached, so checking the version a second time is extremely fast.
*/
static inline bool IsAtLeastRS2() noexcept
{
return ApiCheck::IsAtLeast<ApiCheck::WindowsVersion::RS2>();
}
/**
Returns true if the app is running on Windows RS3 or a later version.
The result is cached, so checking the version a second time is extremely fast.
*/
static inline bool IsAtLeastRS3() noexcept
{
return ApiCheck::IsAtLeast<ApiCheck::WindowsVersion::RS3>();
}
/**
Returns true if the app is running on Windows RS4 or a later version.
The result is cached, so checking the version a second time is extremely fast.
*/
static inline bool IsAtLeastRS4() noexcept
{
return ApiCheck::IsAtLeast<ApiCheck::WindowsVersion::RS4>();
}
/**
Returns true if the app is running on Windows RS5 or a later version.
The result is cached, so checking the version a second time is extremely fast.
*/
static inline bool IsAtLeastRS5() noexcept
{
return ApiCheck::IsAtLeast<ApiCheck::WindowsVersion::RS5>();
}
/**
Returns true if the app is running on Windows 19H1 or a later version.
The result is cached, so checking the version a second time is extremely fast.
*/
static inline bool IsAtLeast19H1() noexcept
{
return ApiCheck::IsAtLeast<ApiCheck::WindowsVersion::CY19H1>();
}
/**
Returns true if the app is running on Windows 20H1 or a later version.
The result is cached, so checking the version a second time is extremely fast.
*/
static inline bool IsAtLeast20H1() noexcept
{
return ApiCheck::IsAtLeast<ApiCheck::WindowsVersion::CY20H1>();
}
// ------------------------------------------------------------
// Specific common APIs
// ------------------------------------------------------------
/**
Returns true if the Windows.UI.Xaml.UIElement.PreviewKeyDown and Up events are available.
The result is cached, so checking for the API a second time is extremely fast.
*/
bool ArePreviewKeyEventsAvailable() noexcept;
/**
Returns true if the Windows.UI.Composition.CompositionLinearGradientBrush API is available.
The result is cached, so checking for the API a second time is extremely fast.
*/
bool IsCompositionLinearGradientBrushAvailable() noexcept;
/**
Returns true if the Windows.UI.Xaml.Media.RevealBrush API is available.
The result is cached, so checking for the API a second time is extremely fast.
*/
bool IsRevealBrushAvailable() noexcept;
/**
Returns true if the deprecated Windows.UI.ViewManagement.StatusBar API is available.
The result is cached, so checking for the API a second time is extremely fast.
*/
bool IsStatusBarAvailable() noexcept;
} // namespace ApiCheck