This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Tool to either invoke a method or read a field on a type. | |
class MyTypeName { | |
using TSelf = MyTypeName; | |
template<typename T> using func_or_field = std::variant< | |
T(TSelf::*)(), | |
T TSelf::*>; | |
template<typename T> auto invoke_func_or_field(func_or_field<T> const& fof) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <versionhelpers.h> | |
bool IsWindows10BuildOrGreater(uint16_t buildNumber) | |
{ | |
OSVERSIONINFOEXW osvi = { sizeof(osvi) }; | |
const auto conditionMask = VerSetConditionMask( | |
VerSetConditionMask( | |
VerSetConditionMask( | |
VerSetConditionMask( | |
0, VER_MAJORVERSION, VER_GREATER_EQUAL), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <wil/resource.h> | |
template<typename Q> bool SubmitThreadpoolLambda(Q&& fn) | |
{ | |
using base_type = std::decay_t<Q>; | |
struct ContextObject : base_type | |
{ | |
ContextObject(Q&& q) : base_type(std::move(q)) {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
std::pair<std::wstring_view, std::wstring_view> SplitAt(std::wstring_view const& source, wchar_t split) | |
{ | |
auto splitpoint = source.find(split); | |
if (splitpoint != std::wstring_view::npos) | |
{ | |
return { source.substr(0, splitpoint), source.substr(splitpoint + 1) }; | |
} | |
else | |
{ | |
return { source, { } }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template<typename TDevice> winrt::IAsyncOperation<TDevice> GetFirstDeviceAsync(winrt::hstring selector) | |
{ | |
// Create a watcher. Try converting all the discovered device information records | |
// into real device instances. When the enumeration is complete, stop everything. | |
auto watcher = winrt::DeviceInformation::CreateWatcher(selector); | |
// DeviceWatcher enumeration ensures that all devices are enumerated, then | |
// raises 'EnumerationCompleted'. We'll use coroutines to model this. | |
winrt::handle event{ ::CreateEvent(nullptr, true, false, nullptr) }; | |
winrt::check_bool(static_cast<bool>(event)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private async void StartTracking_Click(object sender, RoutedEventArgs e) | |
{ | |
FolderPicker p = new FolderPicker(); | |
p.FileTypeFilter.Add(".txt"); | |
p.FileTypeFilter.Add(".jpg"); | |
var f = await p.PickSingleFolderAsync(); | |
var t = f.TryGetChangeTracker(); | |
if (t != null) | |
{ | |
t.Enable(); |
NewerOlder