diff --git a/src/User32/PublicAPI.Unshipped.txt b/src/User32/PublicAPI.Unshipped.txt index 040172cd..563e78bc 100644 --- a/src/User32/PublicAPI.Unshipped.txt +++ b/src/User32/PublicAPI.Unshipped.txt @@ -99,6 +99,13 @@ PInvoke.User32.EnumDisplayDevicesFlags.EDD_GET_DEVICE_INTERFACE_NAME = 1 -> PInv PInvoke.User32.EnumDisplaySettingsExFlags PInvoke.User32.EnumDisplaySettingsExFlags.EDS_RAWMODE = 2 -> PInvoke.User32.EnumDisplaySettingsExFlags PInvoke.User32.EnumDisplaySettingsExFlags.EDS_ROTATEDMODE = 4 -> PInvoke.User32.EnumDisplaySettingsExFlags +PInvoke.User32.ICONINFO +PInvoke.User32.ICONINFO.ICONINFO() -> void +PInvoke.User32.ICONINFO.fIcon -> bool +PInvoke.User32.ICONINFO.xHotspot -> int +PInvoke.User32.ICONINFO.yHotspot -> int +PInvoke.User32.ICONINFO.hbmMask -> System.IntPtr +PInvoke.User32.ICONINFO.hbmColor -> System.IntPtr PInvoke.User32.LASTINPUTINFO PInvoke.User32.LASTINPUTINFO.LASTINPUTINFO() -> void PInvoke.User32.LASTINPUTINFO.cbSize -> int @@ -176,6 +183,7 @@ PInvoke.User32.StaticControlWindowStyles.SS_WORDELLIPSIS = PInvoke.User32.Static PInvoke.User32.WindowStylesEx.WS_EX_NOREDIRECTIONBITMAP = 2097152 -> PInvoke.User32.WindowStylesEx const PInvoke.User32.ENUM_CURRENT_SETTINGS = 4294967295 -> uint const PInvoke.User32.ENUM_REGISTRY_SETTINGS = 4294967294 -> uint +const PInvoke.User32.ASFW_ANY = 4294967295 -> uint static PInvoke.User32.ChangeWindowMessageFilterEx(System.IntPtr hwnd, uint message, uint action, System.IntPtr pChangeFilterStruct) -> bool static PInvoke.User32.ChangeWindowMessageFilterEx(System.IntPtr hwnd, uint message, uint action, ref PInvoke.User32.CHANGEFILTERSTRUCT? pChangeFilterStruct) -> bool static PInvoke.User32.CreateCursor(System.IntPtr hInst, int xHotspot, int yHotSpot, int nWidth, int nHeight, System.ReadOnlySpan pvANDPlane, System.ReadOnlySpan pvXORPlane) -> PInvoke.User32.SafeCursorHandle @@ -192,11 +200,21 @@ static PInvoke.User32.EnumDisplaySettingsEx(System.ReadOnlySpan lpszDevice static PInvoke.User32.EnumDisplaySettingsEx(char[] lpszDeviceName, uint iModeNum, ref PInvoke.DEVMODE lpDevMode, PInvoke.User32.EnumDisplaySettingsExFlags dwFlags) -> bool static PInvoke.User32.GetClassName(System.IntPtr hWnd, System.Span lpClassName) -> int static PInvoke.User32.GetClipboardFormatName(int format, System.Span lpszFormatName) -> int +static PInvoke.User32.GetIconInfo(PInvoke.User32.Cursors cursor, out PInvoke.User32.ICONINFO piconinfo) -> bool +static PInvoke.User32.GetIconInfo(PInvoke.User32.Cursors cursor, PInvoke.User32.ICONINFO* piconinfo) -> bool +static PInvoke.User32.GetIconInfo(PInvoke.User32.Cursors cursor, System.IntPtr piconinfo) -> bool +static PInvoke.User32.GetIconInfo(PInvoke.User32.Icons icon, out PInvoke.User32.ICONINFO piconinfo) -> bool +static PInvoke.User32.GetIconInfo(PInvoke.User32.Icons icon, PInvoke.User32.ICONINFO* piconinfo) -> bool +static PInvoke.User32.GetIconInfo(PInvoke.User32.Icons icon, System.IntPtr piconinfo) -> bool +static PInvoke.User32.GetIconInfo(System.IntPtr hIcon, System.IntPtr piconinfo) -> bool +static PInvoke.User32.GetIconInfo(System.IntPtr hIcon, out PInvoke.User32.ICONINFO piconinfo) -> bool static PInvoke.User32.GetLastInputInfo(System.IntPtr plii) -> bool static PInvoke.User32.GetLastInputInfo(out PInvoke.User32.LASTINPUTINFO plii) -> bool static PInvoke.User32.GetMenuString(System.IntPtr hMenu, uint uIDItem, System.Span lpString, PInvoke.User32.GetMenuStateFlags flags) -> int static PInvoke.User32.GetMonitorInfo(System.IntPtr hMonitor, PInvoke.User32.MONITORINFOEX* lpmi) -> bool static PInvoke.User32.GetMonitorInfo(System.IntPtr hMonitor, out PInvoke.User32.MONITORINFOEX lpmi) -> bool +static PInvoke.User32.GetWindowLongPtr(System.IntPtr hWnd, PInvoke.User32.WindowLongIndexFlags nIndex) -> void* +static PInvoke.User32.GetWindowLongPtr_IntPtr(System.IntPtr hWnd, PInvoke.User32.WindowLongIndexFlags nIndex) -> System.IntPtr static PInvoke.User32.GetWindowText(System.IntPtr hWnd, System.Span lpString) -> int static PInvoke.User32.LASTINPUTINFO.Create() -> PInvoke.User32.LASTINPUTINFO static PInvoke.User32.LoadCursor(System.IntPtr hInstance, System.ReadOnlySpan lpCursorName) -> PInvoke.User32.SafeCursorHandle @@ -211,11 +229,17 @@ static PInvoke.User32.MsgWaitForMultipleObjectsEx(uint nCount, System.ReadOnlySp static PInvoke.User32.QueryDisplayConfig(uint Flags, ref int pNumPathArrayElements, System.Span pPathInfoArray, ref int pNumModeInfoArrayElements, System.Span pModeInfoArray, PInvoke.User32.DISPLAYCONFIG_TOPOLOGY_ID pCurrentTopologyId) -> int static PInvoke.User32.RealGetWindowClass(System.IntPtr hwnd, System.Span pszType) -> uint static PInvoke.User32.SendInput(int nInputs, System.ReadOnlySpan pInputs, int cbSize) -> uint +static extern PInvoke.User32.AllowSetForegroundWindow(int dwProcessId) -> bool +static extern PInvoke.User32.BringWindowToTop(System.IntPtr hWnd) -> bool static extern PInvoke.User32.ChangeWindowMessageFilterEx(System.IntPtr hwnd, uint message, uint action, PInvoke.User32.CHANGEFILTERSTRUCT* pChangeFilterStruct) -> bool +static extern PInvoke.User32.DestroyIcon(System.IntPtr hIcon) -> int +static extern PInvoke.User32.GetIconInfo(System.IntPtr hIcon, PInvoke.User32.ICONINFO* piconinfo) -> bool static extern PInvoke.User32.EnumChildWindows(System.IntPtr hWndParent, System.IntPtr lpEnumFunc, System.IntPtr lParam) -> bool static extern PInvoke.User32.EnumDisplayDevices(char* lpDevice, uint iDevNum, PInvoke.DISPLAY_DEVICE* lpDisplayDevice, PInvoke.User32.EnumDisplayDevicesFlags dwFlags) -> bool static extern PInvoke.User32.EnumDisplaySettings(char* lpszDeviceName, uint iModeNum, PInvoke.DEVMODE* lpDevMode) -> bool static extern PInvoke.User32.EnumDisplaySettingsEx(char* lpszDeviceName, uint iModeNum, PInvoke.DEVMODE* lpDevMode, PInvoke.User32.EnumDisplaySettingsExFlags dwFlags) -> bool +static extern PInvoke.User32.EnumThreadWindows(int dwThreadId, PInvoke.User32.WNDENUMPROC lpfn, System.IntPtr lParam) -> bool +static extern PInvoke.User32.FlashWindow(System.IntPtr hWnd, bool bInvert) -> bool static extern PInvoke.User32.GetLastInputInfo(PInvoke.User32.LASTINPUTINFO* plii) -> bool static extern PInvoke.User32.GetParent(System.IntPtr hWnd) -> System.IntPtr static extern PInvoke.User32.GetProp(System.IntPtr hWnd, int atom) -> System.IntPtr @@ -225,5 +249,17 @@ static extern PInvoke.User32.RemoveProp(System.IntPtr hWnd, int atom) -> System. static extern PInvoke.User32.RemoveProp(System.IntPtr hWnd, string lpString) -> System.IntPtr static extern PInvoke.User32.SetProp(System.IntPtr hWnd, int atom, System.IntPtr hData) -> bool static extern PInvoke.User32.SetProp(System.IntPtr hWnd, string lpString, System.IntPtr hData) -> bool +static extern PInvoke.User32.ShowWindowAsync(System.IntPtr hWnd, PInvoke.User32.WindowShowStyle nCmdShow) -> bool static extern PInvoke.User32.UnregisterClass(string lpClassName, System.IntPtr hInstance) -> bool -static readonly PInvoke.User32.DPI_AWARENESS_CONTEXT_UNAWARE_GDISCALED -> System.IntPtr \ No newline at end of file +static readonly PInvoke.User32.DPI_AWARENESS_CONTEXT_UNAWARE_GDISCALED -> System.IntPtr +PInvoke.User32.Icons +PInvoke.User32.Icons.IDI_APPLICATION = 32512 -> PInvoke.User32.Icons +PInvoke.User32.Icons.IDI_ASTERISK = 32516 -> PInvoke.User32.Icons +PInvoke.User32.Icons.IDI_ERROR = 32513 -> PInvoke.User32.Icons +PInvoke.User32.Icons.IDI_EXCLAMATION = 32515 -> PInvoke.User32.Icons +PInvoke.User32.Icons.IDI_HAND = 32513 -> PInvoke.User32.Icons +PInvoke.User32.Icons.IDI_INFORMATION = 32516 -> PInvoke.User32.Icons +PInvoke.User32.Icons.IDI_QUESTION = 32514 -> PInvoke.User32.Icons +PInvoke.User32.Icons.IDI_SHIELD = 32518 -> PInvoke.User32.Icons +PInvoke.User32.Icons.IDI_WARNING = 32515 -> PInvoke.User32.Icons +PInvoke.User32.Icons.IDI_WINLOGO = 32517 -> PInvoke.User32.Icons \ No newline at end of file diff --git a/src/User32/User32+ICONINFO.cs b/src/User32/User32+ICONINFO.cs new file mode 100644 index 00000000..2b719699 --- /dev/null +++ b/src/User32/User32+ICONINFO.cs @@ -0,0 +1,51 @@ +// Copyright © .NET Foundation and Contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +namespace PInvoke +{ + using System; + + /// + /// Contains the nested type. + /// + public partial class User32 + { + /// + /// Contains information about an icon or a cursor. + /// + public struct ICONINFO + { + /// + /// Contains information about an icon or a cursor. + /// + public bool fIcon; + + /// + /// The x-coordinate of a cursor's hot spot. If this structure defines an icon, + /// the hot spot is always in the center of the icon, and this member is ignored. + /// + public int xHotspot; + + /// + /// The y-coordinate of the cursor's hot spot. If this structure defines an icon, + /// the hot spot is always in the center of the icon, and this member is ignored. + /// + public int yHotspot; + + /// + /// The icon bitmask bitmap. If this structure defines a black and white icon, this bitmask + /// is formatted so that the upper half is the icon AND bitmask and the lower half is the icon + /// XOR bitmask. Under this condition, the height should be an even multiple of two. + /// If this structure defines a color icon, this mask only defines the AND bitmask of the icon. + /// + public IntPtr hbmMask; + + /// + /// A handle to the icon color bitmap. This member can be optional if this structure defines + /// a black and white icon. The AND bitmask of hbmMask is applied with the SRCAND flag to the destination; + /// subsequently, the color bitmap is applied (using XOR) to the destination by using the SRCINVERT flag. + /// + public IntPtr hbmColor; + } + } +} diff --git a/src/User32/User32+Icons.cs b/src/User32/User32+Icons.cs new file mode 100644 index 00000000..0cea2a92 --- /dev/null +++ b/src/User32/User32+Icons.cs @@ -0,0 +1,47 @@ +// Copyright © .NET Foundation and Contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +namespace PInvoke +{ + /// + /// Contains the nested type. + /// + public static partial class User32 + { + /// + /// Represents system predefined cursors. + /// + public enum Icons + { + /// Default application icon. + IDI_APPLICATION = 32512, + + /// Asterisk icon. Same as IDI_INFORMATION. + IDI_ASTERISK = 32516, + + /// Hand-shaped icon. + IDI_ERROR = 32513, + + /// Exclamation point icon.Same as IDI_WARNING. + IDI_EXCLAMATION = 32515, + + /// Hand-shaped icon.Same as IDI_ERROR. + IDI_HAND = 32513, + + /// Asterisk icon. + IDI_INFORMATION = 32516, + + /// Question mark icon. + IDI_QUESTION = 32514, + + /// Security Shield icon. + IDI_SHIELD = 32518, + + /// Exclamation point icon. + IDI_WARNING = 32515, + + /// Default application icon. Windows 2000: Windows logo icon. + IDI_WINLOGO = 32517, + } + } +} diff --git a/src/User32/User32.Helpers.cs b/src/User32/User32.Helpers.cs index ee05c102..22fef02c 100644 --- a/src/User32/User32.Helpers.cs +++ b/src/User32/User32.Helpers.cs @@ -460,6 +460,55 @@ public static unsafe WINDOWPLACEMENT GetWindowPlacement(IntPtr hWnd) } } + /// + /// Retrieves information about the specified window. The function also retrieves the value at a specified offset into the extra window memory. + /// + /// A handle to the window and, indirectly, the class to which the window belongs. + /// The zero-based offset to the value to be set. Valid values are in the range zero + /// through the number of bytes of extra window memory, minus the size of a LONG_PTR. To set any other value, + /// specify one of the following values. + /// + /// + /// ValueMeaning + /// GWL_EXSTYLE(-20)Retrieves the extended window styles. + /// GWLP_HINSTANCE(-6)Retrieves a handle to the application instance. + /// GWLP_HWNDPARENT(-8)Retrieves a handle to the parent window, if there is one. + /// GWLP_ID(-12)Retrieves the identifier of the window. + /// GWL_STYLE (-16)Retrieves the window styles. + /// GWLP_USERDATARetrieves the user data associated with the window. This data is intended for use by the application that created the window. Its value is initially zero. + /// GWLP_WNDPROC (-4)Retrieves the pointer to the window procedure, or a handle representing the pointer to the window procedure. You must use the CallWindowProc function to call the window procedure. + /// + /// + /// The following values are also available when the hWnd parameter identifies a dialog box. + /// + /// + /// ValueMeaning + /// DWLP_DLGPROC (DWLP_MSGRESULT + sizeof(LRESULT))Retrieves the pointer to the dialog box procedure, or a handle representing the pointer to the dialog box procedure. You must use the CallWindowProc function to call the dialog box procedure. + /// DWLP_MSGRESULT (0)Retrieves the return value of a message processed in the dialog box procedure. + /// DWLP_USER (DWLP_DLGPROC + sizeof(DLGPROC))Retrieves extra information private to the application, such as handles or pointers. + /// + /// + /// + /// + /// If the function succeeds, the return value is the requested value. + /// If the function fails, the return value is zero. To get extended error information, call GetLastError. + /// If SetWindowLong or SetWindowLongPtr has not been called previously, GetWindowLongPtr returns zero for values in the extra window or class memory. + /// + /// + /// Reserve extra window memory by specifying a nonzero value in the cbWndExtra member of the WNDCLASSEX structure used with the RegisterClassEx function. + /// + public static unsafe void* GetWindowLongPtr(IntPtr hWnd, WindowLongIndexFlags nIndex) + { + if (IntPtr.Size == 8) + { + return GetWindowLongPtr64(hWnd, nIndex); + } + else + { + return (void*)GetWindowLong(hWnd, nIndex); + } + } + /// [NoFriendlyOverloads] public static unsafe bool GetMonitorInfo( @@ -481,5 +530,55 @@ public static unsafe bool GetMonitorInfo( return GetMonitorInfo(hMonitor, lpmiLocal); } } + + /// + /// Retrieves information about the specified icon or cursor. + /// + /// + /// + /// GetIconInfo creates bitmaps for the hbmMask and hbmCol or members of ICONINFO. The calling application + /// must manage these bitmaps and delete them when they are no longer necessary. + /// + /// + /// DPI Virtualization: This API does not participate in DPI virtualization. The output returned is not + /// affected by the DPI of the calling thread. + /// + /// + /// The cursor + /// A pointer to an ICONINFO structure. The function fills in the structure's members. + /// + /// If the function succeeds, the return value is nonzero and the function fills in the members of the specified ICONINFO structure. + /// If the function fails, the return value is zero. To get extended error information, call GetLastError. + /// by dwThreadId, the return value is FALSE. + /// + public static unsafe bool GetIconInfo(Cursors cursor, [Friendly(FriendlyFlags.Out)] ICONINFO* piconinfo) + { + return GetIconInfo(new IntPtr(MAKEINTRESOURCE((int)cursor)), piconinfo); + } + + /// + /// Retrieves information about the specified icon or cursor. + /// + /// + /// + /// GetIconInfo creates bitmaps for the hbmMask and hbmCol or members of ICONINFO. The calling application + /// must manage these bitmaps and delete them when they are no longer necessary. + /// + /// + /// DPI Virtualization: This API does not participate in DPI virtualization. The output returned is not + /// affected by the DPI of the calling thread. + /// + /// + /// The icon + /// A pointer to an ICONINFO structure. The function fills in the structure's members. + /// + /// If the function succeeds, the return value is nonzero and the function fills in the members of the specified ICONINFO structure. + /// If the function fails, the return value is zero. To get extended error information, call GetLastError. + /// by dwThreadId, the return value is FALSE. + /// + public static unsafe bool GetIconInfo(Icons icon, [Friendly(FriendlyFlags.Out)] ICONINFO* piconinfo) + { + return GetIconInfo(new IntPtr(MAKEINTRESOURCE((int)icon)), piconinfo); + } } } diff --git a/src/User32/User32.cs b/src/User32/User32.cs index 5aa1adf3..97267dbe 100644 --- a/src/User32/User32.cs +++ b/src/User32/User32.cs @@ -66,6 +66,8 @@ public static partial class User32 public const uint ENUM_REGISTRY_SETTINGS = unchecked((uint)-2); + public const uint ASFW_ANY = unchecked((uint)-1); + /// /// A bitmap that is drawn by the window that owns the menu. The application must process the WM_MEASUREITEM and /// WM_DRAWITEM messages. @@ -686,6 +688,28 @@ public static extern IntPtr FindWindowEx( [return: MarshalAs(UnmanagedType.Bool)] public static extern bool ShowWindow(IntPtr hWnd, WindowShowStyle nCmdShow); + /// + /// Sets the show state of a window without waiting for the operation to complete. + /// + /// + /// + /// This function posts a show-window event to the message queue of the given window. + /// An application can use this function to avoid becoming nonresponsive while waiting for a + /// nonresponsive application to finish processing a show-window event. + /// + /// + /// Handle to the window. + /// + /// Controls how the window is to be shown. For a list of possible values, see the + /// description of the function. + /// + /// + /// If the operation was successfully started, the return value is nonzero. + /// + [DllImport(nameof(User32))] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool ShowWindowAsync(IntPtr hWnd, WindowShowStyle nCmdShow); + /// /// Retrieves a handle to the desktop window. The desktop window covers the entire screen. The desktop window is the area on top of which other windows are painted. /// @@ -995,6 +1019,23 @@ public static extern int CallNextHookEx( [return: MarshalAs(UnmanagedType.Bool)] public static extern bool FlashWindowEx(ref FLASHWINFO pwfi); + /// + /// Flashes the specified window one time. It does not change the active state of the window. + /// To flash the window a specified number of times, use the FlashWindowEx function. + /// + /// A handle to the window to be flashed. The window can be either open or minimized. + /// + /// If this parameter is TRUE, the window is flashed from one state to the other. If it is FALSE, the window is returned to its original state (either active or inactive). + /// When an application is minimized and this parameter is TRUE, the taskbar window button flashes active/inactive. If it is FALSE, the taskbar window button flashes inactive, meaning that it does not change colors. It flashes, as if it were being redrawn, but it does not provide the visual invert clue to the user. + /// + /// + /// The return value specifies the window's state before the call to the FlashWindow function. If the window + /// caption was drawn as active before the call, the return value is nonzero. Otherwise, the return value is zero. + /// + [DllImport(nameof(User32), SetLastError = true)] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool FlashWindow(IntPtr hWnd, bool bInvert); + /// /// Enables the application to access the window menu (also known as the system menu or the control menu) for /// copying and modifying. @@ -4123,6 +4164,142 @@ public static extern unsafe bool GetLastInputInfo( [DllImport(nameof(User32), SetLastError = true)] public static extern IntPtr RemoveProp(IntPtr hWnd, int atom); + /// + /// Enables the specified process to set the foreground window using the SetForegroundWindow function. + /// The calling process must already be able to set the foreground window. + /// For more information, see Remarks later in this topic. + /// + /// + /// + /// The system restricts which processes can set the foreground window. + /// A process can set the foreground window only if one of the following conditions is true: + /// + /// The process is the foreground process. + /// The process was started by the foreground process. + /// The process received the last input event. + /// There is no foreground process. + /// The foreground process is being debugged. + /// The foreground is not locked (see LockSetForegroundWindow). + /// The foreground lock time-out has expired (see SPI_GETFOREGROUNDLOCKTIMEOUT in SystemParametersInfo). + /// No menus are active. + /// + /// + /// + /// A process that can set the foreground window can enable another process to set the foreground window by calling + /// AllowSetForegroundWindow. The process specified by dwProcessId loses the ability to set the foreground window + /// the next time the user generates input, unless the input is directed at that process, or the next time a process + /// calls AllowSetForegroundWindow, unless that process is specified. + /// + /// + /// The identifier of the process that will be enabled to set the foreground window. + /// If this parameter is ASFW_ANY, all processes will be enabled to set the foreground window. + /// + /// If the function succeeds, the return value is nonzero. + /// If the function fails, the return value is zero. The function will fail if the calling + /// process cannot set the foreground window. To get extended error information, call GetLastError. + /// + [DllImport(nameof(User32), SetLastError = true)] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool AllowSetForegroundWindow(int dwProcessId); + + /// + /// Brings the specified window to the top of the Z order. If the window is a top-level window, it is activated. + /// If the window is a child window, the top-level parent window associated with the child window is activated. + /// + /// + /// + /// Use the BringWindowToTop function to uncover any window that is partially or completely obscured by other windows. + /// An application can use this function to avoid becoming nonresponsive while waiting for a + /// nonresponsive application to finish processing a show-window event. + /// + /// + /// Calling this function is similar to calling the SetWindowPos function to change a window's position + /// in the Z order. BringWindowToTop does not make a window a top-level window. + /// + /// + /// A handle to the window to bring to the top of the Z order. + /// + /// If the function succeeds, the return value is nonzero. + /// If the function fails, the return value is zero. To get extended error information, call GetLastError. + /// + [DllImport(nameof(User32), SetLastError = true)] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool BringWindowToTop(IntPtr hWnd); + + /// + /// Enumerates all nonchild windows associated with a thread by passing the handle to each window, in turn, + /// to an application-defined callback function. EnumThreadWindows continues until the last window is enumerated + /// or the callback function returns FALSE. To enumerate child windows of a particular window, use the EnumChildWindows function. + /// + /// The identifier of the thread whose windows are to be enumerated. + /// A pointer to an application-defined callback function. For more information, see EnumThreadWndProc. + /// An application-defined value to be passed to the callback function. + /// + /// If the callback function returns TRUE for all windows in the thread specified by dwThreadId, the return value is TRUE. + /// + /// If the callback function returns FALSE on any enumerated window, or if there are no windows found in the thread specified + /// by dwThreadId, the return value is FALSE. + /// + /// + [DllImport(nameof(User32))] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool EnumThreadWindows(int dwThreadId, WNDENUMPROC lpfn, IntPtr lParam); + + /// + /// Destroys an icon and frees any memory the icon occupied. + /// + /// + /// + /// It is only necessary to call DestroyIcon for icons and cursors created with the following functions: + /// CreateIconFromResourceEx (if called without the LR_SHARED flag), CreateIconIndirect, and CopyIcon. + /// Do not use this function to destroy a shared icon. A shared icon is valid as long as the module from which + /// it was loaded remains in memory. The following functions obtain a shared icon. + /// + /// LoadIcon + /// LoadImage (if you use the LR_SHARED flag) + /// CopyImage (if you use the LR_COPYRETURNORG flag and the hImage parameter is a shared icon) + /// CreateIconFromResource + /// CreateIconFromResourceEx (if you use the LR_SHARED flag) + /// + /// + /// + /// A handle to the icon to be destroyed. The icon must not be in use. + /// + /// If the function succeeds, the return value is nonzero. + /// + /// If the function fails, the return value is zero. To get extended error information, call GetLastError. + /// by dwThreadId, the return value is FALSE. + /// + /// + [DllImport(nameof(User32), SetLastError = true)] + public static extern int DestroyIcon(IntPtr hIcon); + + /// + /// Retrieves information about the specified icon or cursor. + /// + /// + /// + /// GetIconInfo creates bitmaps for the hbmMask and hbmCol or members of ICONINFO. The calling application + /// must manage these bitmaps and delete them when they are no longer necessary. + /// + /// + /// DPI Virtualization: This API does not participate in DPI virtualization. The output returned is not + /// affected by the DPI of the calling thread. + /// + /// + /// + /// A handle to the icon or cursor. To retrieve information about a standard icon or cursor, use the respective overloads of GetIconInfo. + /// + /// A pointer to an ICONINFO structure. The function fills in the structure's members. + /// + /// If the function succeeds, the return value is nonzero and the function fills in the members of the specified ICONINFO structure. + /// If the function fails, the return value is zero. To get extended error information, call GetLastError. + /// by dwThreadId, the return value is FALSE. + /// + [DllImport(nameof(User32), SetLastError = true)] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern unsafe bool GetIconInfo(IntPtr hIcon, [Friendly(FriendlyFlags.Out)] ICONINFO* piconinfo); + /// /// The BeginPaint function prepares the specified window for painting and fills a structure with information about the painting. /// @@ -4411,5 +4588,8 @@ private static extern unsafe IntPtr CreateWindowEx( /// [DllImport(nameof(User32), SetLastError = true, EntryPoint = "SetWindowLongPtr")] private static extern unsafe void* SetWindowLongPtr64(IntPtr hWnd, WindowLongIndexFlags nIndex, void* dwNewLong); + + [DllImport(nameof(User32), SetLastError = true, EntryPoint = "GetWindowLongPtr")] + private static extern unsafe void* GetWindowLongPtr64(IntPtr hWnd, WindowLongIndexFlags nIndex); } }