Skip to content

Instantly share code, notes, and snippets.

View kennykerr's full-sized avatar

Kenny Kerr kennykerr

View GitHub Profile
#include <winrt/Windows.System.h>
#include <winrt/Windows.UI.Composition.Desktop.h>
#include <windows.ui.composition.interop.h>
#include <DispatcherQueue.h>
extern "C" IMAGE_DOS_HEADER __ImageBase;
using namespace winrt;
using namespace Windows::UI;
using namespace Windows::UI::Composition;
@kennykerr
kennykerr / SerialNumber.cpp
Last active November 17, 2020 21:57
Reading the computer's serial number
#include "winrt/Windows.System.Profile.SystemManufacturers.h"
using namespace winrt::Windows::System::Profile::SystemManufacturers;
int main()
{
winrt::init_apartment();
printf("Serial number = %ls\n", SmbiosInformation::SerialNumber().c_str());
}
@kennykerr
kennykerr / GetFactoryReportAsync.cpp
Last active February 1, 2018 05:04
Builds a WinRT factory quality report
#include "winrt/base.h"
#include <set>
using namespace winrt;
using namespace Windows::Foundation;
using namespace std::chrono_literals;
extern "C"
{
HRESULT __stdcall OS_RoGetActivationFactory(HSTRING classId, GUID const& iid, void** factory);
@kennykerr
kennykerr / gclip.cpp
Last active April 26, 2018 09:53
Generates a GUID and copies it to the clipboard.
// cl /EHsc /std:c++17 /O2 gclip.cpp
// Requires VS 2017 15.6+ and the RS4 Windows SDK.
#pragma comment(lib, "windowsapp")
#pragma comment(lib, "ole32")
#include <winrt/Windows.ApplicationModel.DataTransfer.h>
#include <windows.h>
using namespace winrt;
#include "winrt/base.h"
#include <Windows.h>
using namespace winrt;
using namespace Windows::Foundation;
using namespace std::chrono;
template <typename...Async>
void wait_for_any(Async&&... async)
{
#include <winrt/Windows.System.h>
#include <ShellScalingAPI.h>
#include <DispatcherQueue.h>
using namespace std::literals;
using namespace winrt;
using namespace Windows::Foundation;
using namespace Windows::System;
auto CreateDispatcherQueueController()
#include <winrt/base.h>
#include <windows.h>
template <typename T>
struct completion_source
{
completion_source()
{
m_signal.attach(CreateEvent(nullptr, true, false, nullptr));
}
#include <unknwn.h>
#include "winrt/Windows.Storage.Streams.h"
using namespace winrt;
using namespace Windows::Foundation;
using namespace Windows::Storage::Streams;
struct __declspec(uuid("905a0fef-bc53-11df-8c49-001e4fc686da")) IBufferByteAccess : ::IUnknown
{
virtual HRESULT __stdcall Buffer(uint8_t** value) noexcept = 0;
#include <windows.h>
#include "winrt/Windows.ApplicationModel.Core.h"
#include "winrt/Windows.UI.Core.h"
using namespace winrt;
using namespace Windows::ApplicationModel::Core;
using namespace Windows::UI::Core;
struct App : implements<App, IFrameworkViewSource, IFrameworkView>
{
#include <string_view>
#include <exception>
#include <assert.h>
using namespace std::literals;
struct guid
{
uint32_t Data1;
uint16_t Data2;