Skip to content

Instantly share code, notes, and snippets.

@Aetopia
Aetopia / Object.cpp
Created February 4, 2025 09:17
A simple C++ class that auto manages a COM pointer's lifetime + COM library initialization & uninitialization.
template <typename T> class Object
{
private:
com_ptr<T> Unknown;
public:
Object(guid const &value)
{
if (FAILED(CoGetContextToken(nullptr)))
init_apartment();
@Aetopia
Aetopia / WinMain.c
Created January 30, 2025 09:54
Get various app properties via "appmodel.h".
#define _MINAPPMODEL_H_
#include <windows.h>
#include <appmodel.h>
#include <tlhelp32.h>
#include <stdio.h>
VOID AppPolicyPrintClrCompat(HANDLE hToken)
{
PCSTR pBuffer = {};
AppPolicyClrCompat _ = {};
http://blogs.msdn.com/b/windowsappdev/archive/2012/09/04/automating-the-testing-of-windows-8-apps.aspx
@Aetopia
Aetopia / WinMain.c
Last active January 29, 2025 08:06
#define _MINAPPMODEL_H_
#include <aclapi.h>
#include <shlwapi.h>
#include <appmodel.h>
#include <initguid.h>
#include <shobjidl.h>
VOID WinMainCRTStartup()
{
@Aetopia
Aetopia / App.cpp
Created January 27, 2025 05:28
Some C++/WinRT class, I made.
#include <windows.h>
#include <initguid.h>
#include <shobjidl.h>
#include <winrt/base.h>
#include <winrt/Windows.ApplicationModel.h>
#include <winrt/Windows.System.h>
#include <winrt/Windows.Foundation.h>
#include <winrt/Windows.Foundation.Collections.h>
#include <winrt/Windows.System.Diagnostics.h>
@Aetopia
Aetopia / JsonValue.cs
Created December 14, 2024 17:11
Experimental DOM API using JsonReaderWriterFactory for .NET Framework 4.8.1.
namespace System.Runtime.Serialization.Json;
using System.IO;
using System.Xml;
using System.Text;
using System.Xml.Linq;
using System.Collections;
using System.Collections.Generic;
sealed class JsonValue : IEnumerable<JsonValue>
@Aetopia
Aetopia / JsonNode.cs
Last active November 11, 2024 14:56
JSON Document Object Model for .NET Framework.
namespace System.Runtime.Serialization.Json;
using System.IO;
using System.Xml;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using System.Collections;
using System.Collections.Generic;
@Aetopia
Aetopia / README.md
Last active November 3, 2024 11:47
How to verify if a valid license exists for a given Microsoft Store app on a given device.

This code sample shows one can verify if a license exists for a given Microsoft Store app.

public static async Task<ReadOnlyDictionary<string, bool>> VerifyAsync(params string[] productIds)
{
    using StringContent content = new($"{{\"IdType\":\"ProductId\",\"ProductIds\":[{string.Join(",", productIds.Select(_ => $"\"{_}\""))}]}}", Encoding.UTF8, "application/json");
    productIds = (await Client.ParseAsync(RequestUris.Item1, content).ConfigureAwait(false)).Descendants("ProductId").Select(_ => _.Value).ToArray();

    using var stream = await Client.GetStreamAsync(string.Format(RequestUris.Item2, string.Join(",", productIds))).ConfigureAwait(false); var source = stream.Parse();
    var result = await LicenseManager.GetSatisfactionInfosAsync(source.Ids("ContentIds"), source.Ids("KeyIds")).AsTask().ConfigureAwait(false);
@Aetopia
Aetopia / UWP.Loader.c
Created September 27, 2024 05:45
UWP Loader: A stub dynamic link library to load other dynamic link libraries into a UWP app in one go.
#define _MINAPPMODEL_H_
#include <initguid.h>
#include <windows.h>
#include <windows.data.json.h>
#include <roapi.h>
#include <winstring.h>
#include <appmodel.h>
DWORD ThreadProc(LPVOID lpParameter)
{
@Aetopia
Aetopia / Benchmarks.cs
Created September 1, 2024 17:34
System.Box
using System;
using BenchmarkDotNet.Attributes;
[MemoryDiagnoser]
public class Benchmarks
{
object @object;
Box<int> box;