Instead of manualy writting DllImports, we just add a package reference to PInvoke.User32 and add following usings:
using PInvoke; using static PInvoke.User32;
to be able to call naturally CreateWindow like that:
IntPtr hwnd = CreateWindow( "BUTTON", string.Empty, // empty window name WindowStyles.WS_OVERLAPPED, 0, 0, 0, 0, IntPtr.Zero, IntPtr.Zero, Process.GetCurrentProcess().Handle, IntPtr.Zero);
Some could prefer to omit the static using to enforce User32.CreateWindow usage.
The down side: it can bring us back many unneeded symbols (perhaps .Net 5.0 trimming can cope with that).