初始化 monorepo: Go后端(7微服务) + Unity客户端(9模块) + 启动器 HTML5原型: Three.js 3D体素世界, Perlin噪声地形, 原版材质, 22种方块 Minecraft创造模式背包: 双栏布局, 拖拽移动物品, 方向性元件引脚 AI助搭策划文档 + 客户端/服务端骨架 + Docker Compose + CI
This commit is contained in:
@@ -0,0 +1,82 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace PCL.Core.Utils.WinRT;
|
||||
|
||||
public static partial class WinRTInterop
|
||||
{
|
||||
// roapi.h
|
||||
[LibraryImport("combase.dll")]
|
||||
private static unsafe partial int RoGetActivationFactory(IntPtr activatableClassId, Guid* iid, IntPtr* factory);
|
||||
[LibraryImport("combase.dll")]
|
||||
private static unsafe partial int RoActivateInstance(IntPtr activatableClassId, IntPtr* instance);
|
||||
|
||||
public static unsafe IntPtr ActivateInstance(ReadOnlySpan<char> activatableClassId)
|
||||
{
|
||||
var instance = IntPtr.Zero;
|
||||
|
||||
fixed (char* pName = activatableClassId)
|
||||
{
|
||||
HStringHeader header;
|
||||
IntPtr hstring;
|
||||
|
||||
Marshal.ThrowExceptionForHR(
|
||||
WindowsCreateStringReference(
|
||||
(ushort*)pName,
|
||||
activatableClassId.Length,
|
||||
(IntPtr*)&header,
|
||||
&hstring));
|
||||
|
||||
Marshal.ThrowExceptionForHR(
|
||||
RoActivateInstance(
|
||||
hstring,
|
||||
&instance));
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
public static unsafe IntPtr GetActivationFactory(ReadOnlySpan<char> activatableClassId, Guid iid)
|
||||
{
|
||||
var factory = IntPtr.Zero;
|
||||
|
||||
fixed (char* pName = activatableClassId)
|
||||
{
|
||||
HStringHeader header;
|
||||
IntPtr hstring;
|
||||
|
||||
Marshal.ThrowExceptionForHR(
|
||||
WindowsCreateStringReference(
|
||||
(ushort*)pName,
|
||||
activatableClassId.Length,
|
||||
(IntPtr*)&header,
|
||||
&hstring));
|
||||
|
||||
Marshal.ThrowExceptionForHR(
|
||||
RoGetActivationFactory(
|
||||
hstring,
|
||||
&iid,
|
||||
&factory));
|
||||
}
|
||||
|
||||
return factory;
|
||||
}
|
||||
|
||||
// winstring.h
|
||||
[LibraryImport("combase.dll")]
|
||||
internal static unsafe partial int WindowsCreateString(ushort* sourceString, int length, IntPtr* hstring);
|
||||
[LibraryImport("combase.dll")]
|
||||
internal static unsafe partial int WindowsCreateStringReference(ushort* sourceString, int length,
|
||||
IntPtr* hstringHeader, IntPtr* hstring);
|
||||
[LibraryImport("combase.dll")]
|
||||
internal static unsafe partial int WindowsDeleteString(IntPtr hstring);
|
||||
[LibraryImport("combase.dll")]
|
||||
internal static unsafe partial char* WindowsGetStringRawBuffer(IntPtr hstring, uint* length);
|
||||
|
||||
// hstring.h
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal unsafe struct HStringHeader
|
||||
{
|
||||
private fixed byte _data[24];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user