With this signatures we can use rc.exe to compile a windows dialog, embed
it as a resource in a .Net executable then load and display it.
There is a working minimal sample in this repository :
https://github.com/vbfox/PInvoke.Forms.Test
<s:String x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=67C1E0A08AB96D4BB8249F5551FDFD07/Text/@EntryValue">// Copyright (c) to owners found in https://github.com/AArnott/pinvoke/blob/master/COPYRIGHT.md. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.

namespace PInvoke
{
 /// <content>
 /// Contains the <see cref="$NESTED$"/> nested type.
 /// </content>
 public partial class $BASECLASS$
 {
 /// <summary>
 /// </summary>
 public class $NESTED$
 {
 $END$
 }
 }
}</s:String></wpf:ResourceDictionary>
// Copyright (c) to owners found in https://github.com/AArnott/pinvoke/blob/master/COPYRIGHT.md. All rights reserved.// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.namespacePInvoke{usingSystem.Runtime.InteropServices;/// <content>/// Contains the <see cref="DLGITEMTEMPLATE"/> nested type./// </content>publicpartialclassUser32{/// <summary>
/// Defines the dimensions and style of a control in a dialog box. One or more of these structures are combined with a
/// <see cref="DLGTEMPLATE" /> structure to form a standard template for a dialog box.
/// </summary>
[StructLayout(LayoutKind.Sequential, Pack = 2)]
publicstructDLGITEMTEMPLATE
{
/// <summary>
/// The style of the control. This member can be a combination of window style values (such as WS_BORDER) and one or
/// more of the control style values (such as BS_PUSHBUTTON and ES_LEFT).
/// </summary>
publicintstyle;
/// <summary>
/// The extended styles for a window. This member is not used to create controls in dialog boxes, but applications that
/// use dialog box templates can use it to create other types of windows.
/// </summary>
publicintdwExtendedStyle;
/// <summary>
/// The x-coordinate, in dialog box units, of the upper-left corner of the control. This coordinate is always relative
/// to the upper-left corner of the dialog box's client area.
/// </summary>
publicbytex;
/// <summary>
/// The y-coordinate, in dialog box units, of the upper-left corner of the control. This coordinate is always relative
/// to the upper-left corner of the dialog box's client area.
/// </summary>
publicbytey;
/// <summary>
/// The width, in dialog box units, of the control.
/// </summary>
publicbytecx;
/// <summary>
/// The height, in dialog box units, of the control.
// Copyright (c) to owners found in https://github.com/AArnott/pinvoke/blob/master/COPYRIGHT.md. All rights reserved.// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.namespacePInvoke{usingSystem.Runtime.InteropServices;/// <content>/// Contains the <see cref="DLGTEMPLATE"/> nested type./// </content>publicpartialclassUser32{/// <summary>
/// Defines the dimensions and style of a dialog box. This structure, always the first in a standard template for a
/// dialog box, also specifies the number of controls in the dialog box and therefore specifies the number of
/// subsequent <see cref="DLGITEMTEMPLATE" /> structures in the template.
/// </summary>
[StructLayout(LayoutKind.Sequential, Pack = 2)]
publicstructDLGTEMPLATE
{
/// <summary>
/// The style of the dialog box. This member can be a combination of window style values (such as WS_CAPTION and
/// WS_SYSMENU) and dialog box style values (such as DS_CENTER).
/// <para>
/// If the style member includes the DS_SETFONT style, the header of the dialog box template contains additional
/// data specifying the font to use for text in the client area and controls of the dialog box. The font data
/// begins on the WORD boundary that follows the title array. The font data specifies a 16-bit point size value and
/// a Unicode font name string. If possible, the system creates a font according to the specified values. Then the
/// system sends a WM_SETFONT message to the dialog box and to each control to provide a handle to the font. If
/// DS_SETFONT is not specified, the dialog box template does not include the font data.
/// </para>
/// <para>The DS_SHELLFONT style is not supported in the DLGTEMPLATE header.</para>
/// </summary>
publicintstyle;
/// <summary>
/// The extended styles for a window. This member is not used to create dialog boxes, but applications that use dialog
/// box templates can use it to create other types of windows.
/// </summary>
publicintdwExtendedStyle;
/// <summary>
/// The number of items in the dialog box.
/// </summary>
publicshortcdit;
/// <summary>
/// The x-coordinate, in dialog box units, of the upper-left corner of the dialog box.
/// </summary>
publicbytex;
/// <summary>
/// The y-coordinate, in dialog box units, of the upper-left corner of the dialog box.
/// </summary>
publicbytey;
/// <summary>
/// The width, in dialog box units, of the dialog box.
/// </summary>
publicbytecx;
/// <summary>
/// The height, in dialog box units, of the dialog box.
// Copyright (c) to owners found in https://github.com/AArnott/pinvoke/blob/master/COPYRIGHT.md. All rights reserved.// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.namespacePInvoke{usingSystem;usingSystem.Runtime.InteropServices;/// <content>/// Contains the <see cref="MSG"/> nested type./// </content>publicpartialclassUser32{/// <summary>
/// Contains message information from a thread's message queue.
/// </summary>
[StructLayout(LayoutKind.Sequential)]
publicstructMSG
{
/// <summary>
/// A handle to the window whose window procedure receives the message. This member is <see cref="IntPtr.Zero" /> when
/// the message is a thread message.
/// </summary>
publicIntPtrhwnd;
/// <summary>
/// The message identifier. Applications can only use the low word; the high word is reserved by the system.
/// </summary>
publicWindowMessagemessage;
/// <summary>
/// Additional information about the message. The exact meaning depends on the value of the message member.
/// </summary>
publicIntPtrwParam;
/// <summary>
/// Additional information about the message. The exact meaning depends on the value of the message member.
/// </summary>
publicIntPtrlParam;
/// <summary>
/// The time at which the message was posted.
/// </summary>
publicinttime;
/// <summary>
/// The cursor position, in screen coordinates, when the message was posted.
// Copyright (c) to owners found in https://github.com/AArnott/pinvoke/blob/master/COPYRIGHT.md. All rights reserved.// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.namespacePInvoke{usingSystem;/// <content>/// Contains the <see cref="PeekMessageRemoveFlags"/> nested type./// </content>publicpartialclassUser32{/// <summary>/// Flags to be passed to the <code>wRemoveMsg</code> parameter of/// <see cref="PeekMessage(IntPtr, IntPtr, WindowMessage, WindowMessage, PeekMessageRemoveFlags)" />/// </summary> [Flags]
publicenumPeekMessageRemoveFlags:uint
{/// <summary>/// Messages are not removed from the queue after processing by/// <see cref="PeekMessage(IntPtr, IntPtr, WindowMessage, WindowMessage, PeekMessageRemoveFlags)" />./// </summary>PM_NOREMOVE=0x0000,/// <summary>/// Messages are removed from the queue after processing by/// <see cref="PeekMessage(IntPtr, IntPtr, WindowMessage, WindowMessage, PeekMessageRemoveFlags)" />./// </summary>PM_REMOVE=0x0001,/// <summary>/// Prevents the system from releasing any thread that is waiting for the caller to go idle (see/// WaitForInputIdle). Combine this value with either <see cref="PM_NOREMOVE" /> or <see cref="PM_REMOVE" />./// </summary>PM_NOYIELD=0x0002,/// <summary>Process mouse and keyboard messages.</summary>PM_QS_INPUT=QueueStatusFlags.QS_INPUT<<16,/// <summary>Process paint messages.</summary>PM_QS_PAINT=QueueStatusFlags.QS_PAINT<<16,/// <summary>Process all posted messages, including timers and hotkeys.</summary>PM_QS_POSTMESSAGE=(QueueStatusFlags.QS_POSTMESSAGE|QueueStatusFlags.QS_HOTKEY|QueueStatusFlags.QS_TIMER)<<16,/// <summary>Process all sent messages.</summary>PM_QS_SENDMESSAGE=QueueStatusFlags.QS_SENDMESSAGE<<16
/// An application-defined or library-defined callback function used with the <see cref="SetWindowsHookEx(WindowsHookType, IntPtr, IntPtr, int)"/> function.
/// This is a generic function to Hook callbacks. For specific callback functions see this <see href="https://msdn.microsoft.com/en-us/library/windows/desktop/ms632589(v=vs.85).aspx" >API documentation on MSDN</see>.
/// Plays a waveform sound. The waveform sound for each sound type is identified by an entry in the registry.
/// </summary>
@ -220,7 +253,6 @@ namespace PInvoke
[DllImport(nameof(User32))]
publicstaticexternIntPtrGetForegroundWindow();
#pragmawarningdisableSA1625// Element documentation must not be copied and pasted
/// <summary>
/// Sends the specified message to a window or windows. The SendMessage function calls the window procedure for the specified window and does not return until the window procedure has processed the message.
/// To send a message and return immediately, use the SendMessageCallback or SendNotifyMessage function. To post a message to a thread's message queue and return immediately, use the PostMessage or PostThreadMessage function.
#pragmawarningrestoreSA1625// Element documentation must not be copied and pasted
/// <summary>
/// Brings the thread that created the specified window into the foreground and activates the window. Keyboard
@ -894,7 +925,7 @@ namespace PInvoke
/// The calling process must have DESKTOP_SWITCHDESKTOP access to the desktop for the SwitchDesktop function to succeed.
/// </summary>
/// <param name="hDesktop">
/// A handle to the desktop. This handle is returned by the <see cref="CreateDesktop(string, string, IntPtr, DesktopCreationFlags, Kernel32.ACCESS_MASK, Kernel32.SECURITY_ATTRIBUTES*)"/> and <see cref="OpenDesktop"/> functions.
/// A handle to the desktop. This handle is returned by the <see cref="CreateDesktop(string, string, IntPtr, DesktopCreationFlags, ACCESS_MASK, Kernel32.SECURITY_ATTRIBUTES*)"/> and <see cref="OpenDesktop"/> functions.
/// This desktop must be associated with the current window station for the process.</param>
/// <returns>If the function succeeds, the return value is true, if it fails, the return value is false.</returns>
/// <remarks>
@ -920,7 +951,7 @@ namespace PInvoke
/// </summary>
/// <param name="hDesktop">
/// A handle to the desktop to be assigned to the calling thread.
/// This handle is returned by the <see cref="CreateDesktop(string, string, IntPtr, DesktopCreationFlags, Kernel32.ACCESS_MASK, Kernel32.SECURITY_ATTRIBUTES*)"/>, <see cref="GetThreadDesktop"/>, <see cref="OpenDesktop"/>, or <see cref="OpenInputDesktop"/> function.
/// This handle is returned by the <see cref="CreateDesktop(string, string, IntPtr, DesktopCreationFlags, ACCESS_MASK, Kernel32.SECURITY_ATTRIBUTES*)"/>, <see cref="GetThreadDesktop"/>, <see cref="OpenDesktop"/>, or <see cref="OpenInputDesktop"/> function.
/// This desktop must be associated with the current window station for the process.
/// </param>
/// <returns>If the function succeeds, the return value is true, if it fails, the return value is false.</returns>
@ -937,7 +968,7 @@ namespace PInvoke
/// <param name="lpszDesktop">The name of the desktop to be opened. Desktop names are case-insensitive. This desktop must belong to the current window station.</param>
/// <param name="dwFlags">Access control flags</param>
/// <param name="fInherit">If this value is true, processes created by this process will inherit the handle. Otherwise, the processes do not inherit this handle.</param>
/// <param name="dwDesiredAccess">The access to the desktop. For a list of access rights, see <see cref="Kernel32.ACCESS_MASK"/>.</param>
/// <param name="dwDesiredAccess">The access to the desktop. For a list of access rights, see <see cref="ACCESS_MASK"/>.</param>
/// <returns>If the function succeeds, the return value is a handle to the opened desktop, if the function fails, the return value is an invalid handle.</returns>
/// <remarks>
/// <para>
@ -955,14 +986,14 @@ namespace PInvoke
stringlpszDesktop,
DesktopCreationFlagsdwFlags,
[MarshalAs(UnmanagedType.Bool)]boolfInherit,
Kernel32.ACCESS_MASK dwDesiredAccess);
ACCESS_MASK dwDesiredAccess);
/// <summary>
/// Enumerates all top-level windows associated with the specified desktop. It passes the handle to each window, in turn, to an application-defined callback function.
/// </summary>
/// <param name="hDesktop">
/// A handle to the desktop whose top-level windows are to be enumerated. This handle is returned by the <see cref="CreateDesktop(string, string, IntPtr, DesktopCreationFlags, Kernel32.ACCESS_MASK, Kernel32.SECURITY_ATTRIBUTES*)"/>, <see cref="GetThreadDesktop"/>, <see cref="OpenDesktop"/>, or <see cref="OpenInputDesktop"/> function,
/// and must have the <see cref="Kernel32.ACCESS_MASK.DesktopSpecificRight.DESKTOP_READOBJECTS"/> access right.
/// A handle to the desktop whose top-level windows are to be enumerated. This handle is returned by the <see cref="CreateDesktop(string, string, IntPtr, DesktopCreationFlags, ACCESS_MASK, Kernel32.SECURITY_ATTRIBUTES*)"/>, <see cref="GetThreadDesktop"/>, <see cref="OpenDesktop"/>, or <see cref="OpenInputDesktop"/> function,
/// and must have the <see cref="ACCESS_MASK.DesktopSpecificRight.DESKTOP_READOBJECTS"/> access right.
/// If this parameter is NULL, the current desktop is used.
/// Enumerates all desktops associated with the specified window station of the calling process. The function passes the name of each desktop, in turn, to an application-defined callback function.
/// </summary>
/// <param name="hWinsta">A handle to the window station whose desktops are to be enumerated. This handle is returned by the <see cref="CreateWindowStation(string, WindowStationCreationFlags, Kernel32.ACCESS_MASK, Kernel32.SECURITY_ATTRIBUTES*)"/>, <see cref="GetProcessWindowStation"/>, or <see cref="OpenWindowStation"/> function, and must have the WINSTA_ENUMDESKTOPS access right.</param>
/// <param name="hWinsta">A handle to the window station whose desktops are to be enumerated. This handle is returned by the <see cref="CreateWindowStation(string, WindowStationCreationFlags, ACCESS_MASK, Kernel32.SECURITY_ATTRIBUTES*)"/>, <see cref="GetProcessWindowStation"/>, or <see cref="OpenWindowStation"/> function, and must have the WINSTA_ENUMDESKTOPS access right.</param>
/// <param name="lParam">An application-defined value to be passed to the callback function.</param>
/// <returns>
@ -1009,7 +1040,7 @@ namespace PInvoke
/// If the callback function fails, the return value is zero. The callback function can call SetLastError to set an error code for the caller to retrieve by calling GetLastError.
/// </returns>
/// <remarks>
/// The EnumDesktops function enumerates only those desktops for which the calling process has the <see cref="Kernel32.ACCESS_MASK.DesktopSpecificRight.DESKTOP_ENUMERATE"/> access right.
/// The EnumDesktops function enumerates only those desktops for which the calling process has the <see cref="ACCESS_MASK.DesktopSpecificRight.DESKTOP_ENUMERATE"/> access right.
/// The EnumDesktops function repeatedly invokes the lpEnumFunc callback function until the last desktop is enumerated or the callback function returns zero.
/// </remarks>
[DllImport(nameof(User32), SetLastError = true)]
@ -1021,7 +1052,7 @@ namespace PInvoke
/// </summary>
/// <param name="dwFlags">Access control flags</param>
/// <param name="fInherit">If this value is true, processes created by this process will inherit the handle. Otherwise, the processes do not inherit this handle.</param>
/// <param name="dwDesiredAccess">The requested access to the desktop. For a list of values, see <see cref="Kernel32.ACCESS_MASK"/>.</param>
/// <param name="dwDesiredAccess">The requested access to the desktop. For a list of values, see <see cref="ACCESS_MASK"/>.</param>
/// <returns>If the function succeeds, the return value is a handle to the opened desktop, if the function fails, the return value is an invalid handle.</returns>
/// Creates a new desktop with the specified heap, associates it with the current window station of the calling process, and assigns it to the calling thread.
@ -1053,8 +1084,8 @@ namespace PInvoke
/// <param name="pDevmode">This parameter is reserved and must be <see cref="IntPtr.Zero"/>.</param>
/// <param name="dwFlags">Access control flags</param>
/// <param name="dwDesiredAccess">
/// The requested access to the desktop. For a list of values, see <see cref="Kernel32.ACCESS_MASK"/>.
/// This parameter must include the <see cref="Kernel32.ACCESS_MASK.DesktopSpecificRight.DESKTOP_CREATEWINDOW"/> access right, because internally <see cref="CreateDesktop(string, string, IntPtr, DesktopCreationFlags, Kernel32.ACCESS_MASK, Kernel32.SECURITY_ATTRIBUTES*)"/> uses the handle to create a window.
/// The requested access to the desktop. For a list of values, see <see cref="ACCESS_MASK"/>.
/// This parameter must include the <see cref="ACCESS_MASK.DesktopSpecificRight.DESKTOP_CREATEWINDOW"/> access right, because internally <see cref="CreateDesktop(string, string, IntPtr, DesktopCreationFlags, ACCESS_MASK, Kernel32.SECURITY_ATTRIBUTES*)"/> uses the handle to create a window.
/// </param>
/// <param name="lpsa">
/// A pointer to a <see cref="Kernel32.SECURITY_ATTRIBUTES"/> structure that determines whether the returned handle can be inherited by child processes. If lpsa is NULL, the handle cannot be inherited.
/// <param name="pDevmode">This parameter is reserved and must be <see cref="IntPtr.Zero"/>.</param>
/// <param name="dwFlags">Access control flags</param>
/// <param name="dwDesiredAccess">
/// The requested access to the desktop. For a list of values, see <see cref="Kernel32.ACCESS_MASK"/>.
/// This parameter must include the <see cref="Kernel32.ACCESS_MASK.DesktopSpecificRight.DESKTOP_CREATEWINDOW"/> access right, because internally <see cref="CreateDesktop(string, string, IntPtr, DesktopCreationFlags, Kernel32.ACCESS_MASK, Kernel32.SECURITY_ATTRIBUTES*)"/> uses the handle to create a window.
/// The requested access to the desktop. For a list of values, see <see cref="ACCESS_MASK"/>.
/// This parameter must include the <see cref="ACCESS_MASK.DesktopSpecificRight.DESKTOP_CREATEWINDOW"/> access right, because internally <see cref="CreateDesktop(string, string, IntPtr, DesktopCreationFlags, ACCESS_MASK, Kernel32.SECURITY_ATTRIBUTES*)"/> uses the handle to create a window.
/// </param>
/// <param name="lpsa">
/// A pointer to a <see cref="Kernel32.SECURITY_ATTRIBUTES"/> structure that determines whether the returned handle can be inherited by child processes. If lpsa is NULL, the handle cannot be inherited.
/// A handle to the desktop to be closed. This can be a handle returned by the <see cref="CreateDesktop(string, string, IntPtr, DesktopCreationFlags, Kernel32.ACCESS_MASK, Kernel32.SECURITY_ATTRIBUTES*)"/>, <see cref="OpenDesktop"/>, or <see cref="OpenInputDesktop"/> functions.
/// A handle to the desktop to be closed. This can be a handle returned by the <see cref="CreateDesktop(string, string, IntPtr, DesktopCreationFlags, ACCESS_MASK, Kernel32.SECURITY_ATTRIBUTES*)"/>, <see cref="OpenDesktop"/>, or <see cref="OpenInputDesktop"/> functions.
/// Do not specify the handle returned by the <see cref="GetThreadDesktop"/> function.
/// </param>
/// <returns>If the function succeeds, the return value is true, if it fails, the return value is false.</returns>
@ -1164,7 +1195,7 @@ namespace PInvoke
/// <summary>
/// Retrieves information about the specified window station or desktop object.
/// </summary>
/// <param name="hObj">A handle to the window station or desktop object. This handle is returned by the <see cref="CreateWindowStation(string, WindowStationCreationFlags, Kernel32.ACCESS_MASK, Kernel32.SECURITY_ATTRIBUTES*)"/>, <see cref="OpenWindowStation"/>, <see cref="CreateDesktop(string, string, IntPtr, DesktopCreationFlags, Kernel32.ACCESS_MASK, Kernel32.SECURITY_ATTRIBUTES*)"/>, or <see cref="OpenDesktop"/> function.</param>
/// <param name="hObj">A handle to the window station or desktop object. This handle is returned by the <see cref="CreateWindowStation(string, WindowStationCreationFlags, ACCESS_MASK, Kernel32.SECURITY_ATTRIBUTES*)"/>, <see cref="OpenWindowStation"/>, <see cref="CreateDesktop(string, string, IntPtr, DesktopCreationFlags, ACCESS_MASK, Kernel32.SECURITY_ATTRIBUTES*)"/>, or <see cref="OpenDesktop"/> function.</param>
/// <param name="nIndex">The information to be retrieved.</param>
/// <param name="pvInfo">A pointer to a buffer to receive the object information.</param>
/// <param name="nLength">The size of the buffer pointed to by the <paramref name="pvInfo"/> parameter, in bytes.</param>
@ -1182,7 +1213,7 @@ namespace PInvoke
/// This enables the process to access objects in the window station such as desktops, the clipboard, and global atoms. All subsequent operations on the window station use the access rights granted to <paramref name="hWinSta"/>.
/// </summary>
/// <param name="hWinSta">
/// A handle to the window station. This can be a handle returned by the <see cref="CreateWindowStation(string, WindowStationCreationFlags, Kernel32.ACCESS_MASK, Kernel32.SECURITY_ATTRIBUTES*)"/>, <see cref="OpenWindowStation"/>, or <see cref="GetProcessWindowStation"/> function.
/// A handle to the window station. This can be a handle returned by the <see cref="CreateWindowStation(string, WindowStationCreationFlags, ACCESS_MASK, Kernel32.SECURITY_ATTRIBUTES*)"/>, <see cref="OpenWindowStation"/>, or <see cref="GetProcessWindowStation"/> function.
/// This window station must be associated with the current session.
/// </param>
/// <returns>If the function succeeds, the return value is true, if it fails, the return value is false.</returns>
@ -1195,7 +1226,7 @@ namespace PInvoke
/// </summary>
/// <param name="hWinsta">
/// A handle to the window station to be closed.
/// This handle is returned by the <see cref="CreateWindowStation(string, WindowStationCreationFlags, Kernel32.ACCESS_MASK, Kernel32.SECURITY_ATTRIBUTES*)"/> or <see cref="OpenWindowStation"/> function.
/// This handle is returned by the <see cref="CreateWindowStation(string, WindowStationCreationFlags, ACCESS_MASK, Kernel32.SECURITY_ATTRIBUTES*)"/> or <see cref="OpenWindowStation"/> function.
/// Do not specify the handle returned by the <see cref="GetProcessWindowStation"/> function.
/// </param>
/// <returns>If the function succeeds, the return value is true, if it fails, the return value is false.</returns>
@ -1225,13 +1256,13 @@ namespace PInvoke
/// Windows XP/2000: This parameter is reserved and must be zero.
/// </param>
/// <param name="dwDesiredAccess">
/// The requested access to the window station. For a list of values, see <see cref="Kernel32.ACCESS_MASK"/>.
/// In addition, you can specify any of the standard access rights, such as <see cref="Kernel32.ACCESS_MASK.StandardRight.READ_CONTROL"/> or <see cref="Kernel32.ACCESS_MASK.StandardRight.WRITE_DAC"/>, and a combination of the window station-specific access rights.
/// The requested access to the window station. For a list of values, see <see cref="ACCESS_MASK"/>.
/// In addition, you can specify any of the standard access rights, such as <see cref="ACCESS_MASK.StandardRight.READ_CONTROL"/> or <see cref="ACCESS_MASK.StandardRight.WRITE_DAC"/>, and a combination of the window station-specific access rights.
/// </param>
/// <param name="lpsa">
/// A pointer to a <see cref="Kernel32.SECURITY_ATTRIBUTES"/> structure that determines whether the returned handle can be inherited by child processes. If lpsa is NULL, the handle cannot be inherited.
/// The <see cref="Kernel32.SECURITY_ATTRIBUTES.lpSecurityDescriptor"/> member of the structure specifies a security descriptor for the new window station.
/// If lpsa is NULL, the window station (and any desktops created within the window) gets a security descriptor that grants <see cref="Kernel32.ACCESS_MASK.GenericRight.GENERIC_ALL"/> access to all users.
/// If lpsa is NULL, the window station (and any desktops created within the window) gets a security descriptor that grants <see cref="ACCESS_MASK.GenericRight.GENERIC_ALL"/> access to all users.
/// </param>
/// <returns>
/// If the function succeeds, the return value is a handle to the newly created window station.
/// If the callback function fails, the return value is zero. The callback function can call SetLastError to set an error code for the caller to retrieve by calling GetLastError.
/// </returns>
/// <remarks>
/// The EnumWindowStations function enumerates only those window stations for which the calling process has the <see cref="Kernel32.ACCESS_MASK.WindowStationSpecificRight.WINSTA_ENUMERATE"/> access right.
/// The EnumWindowStations function enumerates only those window stations for which the calling process has the <see cref="ACCESS_MASK.WindowStationSpecificRight.WINSTA_ENUMERATE"/> access right.
/// EnumWindowStations repeatedly invokes the <paramref name="lpEnumFunc"/> callback function until the last window station is enumerated or the callback function returns FALSE.
/// Retrieves a message from the calling thread's message queue. The function dispatches incoming sent messages until a
/// posted message is available for retrieval.
/// <para>
/// Unlike <see cref="GetMessage(MSG*, IntPtr, WindowMessage,WindowMessage)" />, the <see cref="PeekMessage(MSG*, IntPtr, WindowMessage,WindowMessage,PeekMessageRemoveFlags)" /> function does not wait for a message to be
/// posted before returning.
/// </para>
/// </summary>
/// <param name="lpMsg">A pointer to an <see cref="MSG" /> structure that receives message information.</param>
/// <param name="hWnd">
/// A handle to the window whose messages are to be retrieved. The window must belong to the current thread.
/// <para>
/// If hWnd is <see cref="IntPtr.Zero" />, PeekMessage retrieves messages for any window that belongs to the
/// current thread, and any messages on the current thread's message queue whose hwnd value is NULL (see the MSG
/// structure). Therefore if hWnd is <see cref="IntPtr.Zero" />, both window messages and thread messages are
/// processed.
/// </para>
/// <para>
/// If hWnd is -1, PeekMessage retrieves only messages on the current thread's message queue whose hwnd value is
/// NULL, that is, thread messages as posted by <see cref="PostMessage(IntPtr, WindowMessage, void*, void*)" />
/// (when the hWnd parameter is <see cref="IntPtr.Zero" />) or <see cref="PostThreadMessage" />.
/// </para>
/// </param>
/// <param name="wMsgFilterMin">
/// <para>
/// The value of the first message in the range of messages to be examined. Use
/// <see cref="WindowMessage.WM_KEYFIRST" /> to specify the first keyboard message or
/// <see cref="WindowMessage.WM_MOUSEFIRST" /> to specify the first mouse message.
/// </para>
/// <para>
/// If wMsgFilterMin and wMsgFilterMax are both <see cref="WindowMessage.WM_NULL" />, PeekMessage returns all
/// available messages (that is, no range filtering is performed).
/// </para>
/// </param>
/// <param name="wMsgFilterMax">
/// <para>
/// The value of the last message in the range of messages to be examined. Use
/// <see cref="WindowMessage.WM_KEYLAST" /> to specify the last keyboard message or
/// <see cref="WindowMessage.WM_MOUSELAST" /> to specify the last mouse message.
/// </para>
/// <para>
/// If wMsgFilterMin and wMsgFilterMax are both <see cref="WindowMessage.WM_NULL" />, PeekMessage returns all
/// available messages (that is, no range filtering is performed).
/// </para>
/// </param>
/// <returns>
/// If the function retrieves a message other than <see cref="WindowMessage.WM_QUIT" />, the return value is nonzero.
/// <para>If the function retrieves the <see cref="WindowMessage.WM_QUIT" /> message, the return value is zero.</para>
/// <para>
/// If there is an error, the return value is -1. For example, the function fails if <paramref name="hWnd" /> is
/// an invalid window handle or <paramref name="lpMsg" /> is an invalid pointer. To get extended error information,
/// call <see cref="GetLastError" />.
/// </para>
/// </returns>
[DllImport(nameof(User32), SetLastError = true)]
publicstaticexternunsafeintGetMessage(
MSG*lpMsg,
IntPtrhWnd,
WindowMessagewMsgFilterMin,
WindowMessagewMsgFilterMax);
/// <summary>
/// Dispatches incoming sent messages, checks the thread message queue for a posted message, and retrieves the message
/// (if any exist).
/// </summary>
/// <param name="lpMsg">A pointer to an <see cref="MSG" /> structure that receives message information.</param>
/// <param name="hWnd">
/// A handle to the window whose messages are to be retrieved. The window must belong to the current thread.
/// <para>
/// If hWnd is <see cref="IntPtr.Zero" />, PeekMessage retrieves messages for any window that belongs to the
/// current thread, and any messages on the current thread's message queue whose hwnd value is NULL (see the MSG
/// structure). Therefore if hWnd is <see cref="IntPtr.Zero" />, both window messages and thread messages are
/// processed.
/// </para>
/// <para>
/// If hWnd is -1, PeekMessage retrieves only messages on the current thread's message queue whose hwnd value is
/// NULL, that is, thread messages as posted by <see cref="PostMessage(IntPtr, WindowMessage, void*, void*)" /> (when the hWnd parameter is
/// <see cref="IntPtr.Zero" />) or
/// <see cref="PostThreadMessage" />.
/// </para>
/// </param>
/// <param name="wMsgFilterMin">
/// <para>
/// The value of the first message in the range of messages to be examined. Use
/// <see cref="WindowMessage.WM_KEYFIRST" /> to specify the first keyboard message or
/// <see cref="WindowMessage.WM_MOUSEFIRST" /> to specify the first mouse message.
/// </para>
/// <para>
/// If wMsgFilterMin and wMsgFilterMax are both <see cref="WindowMessage.WM_NULL" />, PeekMessage returns all
/// available messages (that is, no range filtering is performed).
/// </para>
/// </param>
/// <param name="wMsgFilterMax">
/// <para>
/// The value of the last message in the range of messages to be examined. Use
/// <see cref="WindowMessage.WM_KEYLAST" /> to specify the last keyboard message or
/// <see cref="WindowMessage.WM_MOUSELAST" /> to specify the last mouse message.
/// </para>
/// <para>
/// If wMsgFilterMin and wMsgFilterMax are both <see cref="WindowMessage.WM_NULL" />, PeekMessage returns all
/// available messages (that is, no range filtering is performed).
/// </para>
/// </param>
/// <param name="wRemoveMsg">Specifies how messages are to be handled</param>
/// <returns>
/// If a message is available, the return value is true.
/// <para>If no messages are available, the return value is false.</para>
/// </returns>
[DllImport(nameof(User32), SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
publicstaticexternunsafeboolPeekMessage(
MSG*lpMsg,
IntPtrhWnd,
WindowMessagewMsgFilterMin,
WindowMessagewMsgFilterMax,
PeekMessageRemoveFlagswRemoveMsg);
/// <summary>
/// Posts a message to the message queue of the specified thread. It returns without waiting for the thread to process
/// the message.
/// </summary>
/// <param name="idThread">
/// The identifier of the thread to which the message is to be posted.
/// <para>
/// The function fails if the specified thread does not have a message queue. The system creates a thread's
/// message queue when the thread makes its first call to one of the User or GDI functions.
/// </para>
/// <para>
/// Message posting is subject to UIPI. The thread of a process can post messages only to posted-message queues
/// of threads in processes of lesser or equal integrity level.
/// </para>
/// <para>
/// This thread must have the SE_TCB_NAME privilege to post a message to a thread that belongs to a process with
/// the same locally unique identifier (LUID) but is in a different desktop. Otherwise, the function fails and
/// A pointer to an <see cref="MSG" /> structure that contains message information retrieved from the
/// calling thread's message queue by using the <see cref="GetMessage(MSG*, IntPtr, WindowMessage,WindowMessage)" /> or <see cref="PeekMessage(MSG*, IntPtr, WindowMessage,WindowMessage,PeekMessageRemoveFlags)" /> function.
/// </param>
/// <returns>
/// If the message is translated (that is, a character message is posted to the thread's message queue), the return
/// value is nonzero.
/// <para>
/// If the message is <see cref="WindowMessage.WM_KEYDOWN" />, <see cref="WindowMessage.WM_KEYUP" />,
/// <see cref="WindowMessage.WM_SYSKEYDOWN" />, or
/// <see cref="WindowMessage.WM_SYSKEYUP" />, the return value is nonzero, regardless of the translation.
/// </para>
/// <para>
/// If the message is not translated (that is, a character message is not posted to the thread's message queue),
/// The <see cref="GetDC"/> function retrieves a handle to a device context (DC) for the client area of a specified window or for the entire screen. You can use the returned handle in subsequent GDI functions to draw in the DC. The device context is an opaque data structure, whose values are used internally by GDI.