Skip to content

Commit ac42e02

Browse files
committed
Add a static method to PCWSTR that allows constructing from a string
1 parent 4575b08 commit ac42e02

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/Files.App.CsWin32/Extras.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,20 @@ public static unsafe nint SetWindowLongPtr(HWND hWnd, WINDOW_LONG_PTR_INDEX nInd
4444
public const int PixelFormat32bppARGB = 2498570;
4545
}
4646

47+
namespace Foundation
48+
{
49+
public partial struct PCWSTR
50+
{
51+
public static unsafe PCWSTR FromString(string value)
52+
{
53+
fixed (char* p = value)
54+
{
55+
return new PCWSTR(p);
56+
}
57+
}
58+
}
59+
}
60+
4761
namespace Extras
4862
{
4963
[GeneratedComInterface, Guid("EACDD04C-117E-4E17-88F4-D1B12B0E3D89"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]

0 commit comments

Comments
 (0)