From ac42e02b4bf17fd259d047e31e464a47d9454a70 Mon Sep 17 00:00:00 2001 From: Lamparter <71598437+Lamparter@users.noreply.github.com> Date: Sat, 17 May 2025 12:19:36 +0100 Subject: [PATCH] Add a static method to PCWSTR that allows constructing from a string --- src/Files.App.CsWin32/Extras.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/Files.App.CsWin32/Extras.cs b/src/Files.App.CsWin32/Extras.cs index 422d9fbdfc68..15aad46052a4 100644 --- a/src/Files.App.CsWin32/Extras.cs +++ b/src/Files.App.CsWin32/Extras.cs @@ -44,6 +44,20 @@ public static unsafe nint SetWindowLongPtr(HWND hWnd, WINDOW_LONG_PTR_INDEX nInd public const int PixelFormat32bppARGB = 2498570; } + namespace Foundation + { + public partial struct PCWSTR + { + public static unsafe PCWSTR FromString(string value) + { + fixed (char* p = value) + { + return new PCWSTR(p); + } + } + } + } + namespace Extras { [GeneratedComInterface, Guid("EACDD04C-117E-4E17-88F4-D1B12B0E3D89"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]