Skip to content
This repository was archived by the owner on Jul 26, 2023. It is now read-only.

Commit 734269d

Browse files
committed
Add UnregisterClass method
Closes #451
1 parent e70ad5a commit 734269d

File tree

2 files changed

+22
-25
lines changed

2 files changed

+22
-25
lines changed

src/User32/PublicAPI.Unshipped.txt

+1-25
Original file line numberDiff line numberDiff line change
@@ -173,36 +173,11 @@ const PInvoke.User32.WAIT_OBJECT_0 = 0 -> uint
173173
const PInvoke.User32.WAIT_TIMEOUT = 258 -> uint
174174
override PInvoke.User32.SafeCursorHandle.IsInvalid.get -> bool
175175
override PInvoke.User32.SafeCursorHandle.ReleaseHandle() -> bool
176-
static PInvoke.User32.AdjustWindowRectEx(System.IntPtr lpRect, PInvoke.User32.WindowStyles dwStyle, bool bMenu, PInvoke.User32.WindowStylesEx dwExStyle) -> bool
177-
static PInvoke.User32.AdjustWindowRectExForDpi(System.IntPtr lpRect, PInvoke.User32.WindowStyles dwStyle, bool bMenu, PInvoke.User32.WindowStylesEx dwExStyle, int dpi) -> bool
178176
static PInvoke.User32.CURSORINFO.Create() -> PInvoke.User32.CURSORINFO
179-
static PInvoke.User32.CreateCursor(System.IntPtr hInst, int xHotspot, int yHotSpot, int nWidth, int nHeight, System.IntPtr pvANDPlane, System.IntPtr pvXORPlane) -> PInvoke.User32.SafeCursorHandle
180-
static PInvoke.User32.CreateCursor(System.IntPtr hInst, int xHotspot, int yHotSpot, int nWidth, int nHeight, byte[] pvANDPlane, byte[] pvXORPlane) -> PInvoke.User32.SafeCursorHandle
181-
static PInvoke.User32.CreateWindowEx(PInvoke.User32.WindowStylesEx dwExStyle, short lpClassName, string lpWindowName, PInvoke.User32.WindowStyles dwStyle, int x, int y, int nWidth, int nHeight, System.IntPtr hWndParent, System.IntPtr hMenu, System.IntPtr hInstance, System.IntPtr lpParam) -> System.IntPtr
182177
static PInvoke.User32.CreateWindowEx(PInvoke.User32.WindowStylesEx dwExStyle, short lpClassName, string lpWindowName, PInvoke.User32.WindowStyles dwStyle, int x, int y, int nWidth, int nHeight, System.IntPtr hWndParent, System.IntPtr hMenu, System.IntPtr hInstance, void* lpParam) -> System.IntPtr
183-
static PInvoke.User32.GetCursorInfo(System.IntPtr pci) -> bool
184-
static PInvoke.User32.GetCursorInfo(out PInvoke.User32.CURSORINFO pci) -> bool
185-
static PInvoke.User32.GetMenuBarInfo(System.IntPtr hwnd, PInvoke.User32.MenuObject idObject, int idItem, System.IntPtr pmbi) -> bool
186-
static PInvoke.User32.GetMenuInfo(System.IntPtr hMenu, System.IntPtr lpMenuInfo) -> bool
187-
static PInvoke.User32.GetMenuItemInfo(System.IntPtr hMenu, uint uItem, bool fByPosition, System.IntPtr lpmii) -> bool
188-
static PInvoke.User32.GetMenuItemInfo(System.IntPtr hMenu, uint uItem, bool fByPosition, ref PInvoke.User32.MENUITEMINFO lpmii) -> bool
189-
static PInvoke.User32.GetMenuItemRect(System.IntPtr hWnd, System.IntPtr hMenu, uint uItem, System.IntPtr lprcItem) -> bool
190-
static PInvoke.User32.GetMenuString(System.IntPtr hMenu, uint uIDItem, System.IntPtr lpString, int cchMax, PInvoke.User32.GetMenuStateFlags flags) -> int
191-
static PInvoke.User32.GetMenuString(System.IntPtr hMenu, uint uIDItem, char[] lpString, int cchMax, PInvoke.User32.GetMenuStateFlags flags) -> int
192178
static PInvoke.User32.GetNextWindow(System.IntPtr hWnd, PInvoke.User32.GetNextWindowCommands wCmd) -> System.IntPtr
193-
static PInvoke.User32.LoadCursor(System.IntPtr hInstance, System.IntPtr lpCursorName) -> PInvoke.User32.SafeCursorHandle
194-
static PInvoke.User32.LoadCursor(System.IntPtr hInstance, char[] lpCursorName) -> PInvoke.User32.SafeCursorHandle
195-
static PInvoke.User32.LoadImage(System.IntPtr hInst, System.IntPtr name, PInvoke.User32.ImageType type, int cx, int cy, PInvoke.User32.LoadImageFlags fuLoad) -> System.IntPtr
196-
static PInvoke.User32.LoadImage(System.IntPtr hInst, char[] name, PInvoke.User32.ImageType type, int cx, int cy, PInvoke.User32.LoadImageFlags fuLoad) -> System.IntPtr
197179
static PInvoke.User32.MENUBARINFO.Create() -> PInvoke.User32.MENUBARINFO
198-
static PInvoke.User32.MsgWaitForMultipleObjectsEx(uint nCount, System.IntPtr pHandles, uint dwMilliseconds, PInvoke.User32.WakeMask dwWakeMask, PInvoke.User32.MsgWaitForMultipleObjectsExFlags dwFlags) -> uint
199-
static PInvoke.User32.MsgWaitForMultipleObjectsEx(uint nCount, System.IntPtr[] pHandles, uint dwMilliseconds, PInvoke.User32.WakeMask dwWakeMask, PInvoke.User32.MsgWaitForMultipleObjectsExFlags dwFlags) -> uint
200-
static PInvoke.User32.SetMenuItemInfo(System.IntPtr hMenu, uint uItem, bool fByPosition, PInvoke.User32.MENUITEMINFO lpmii) -> bool
201-
static PInvoke.User32.SetMenuItemInfo(System.IntPtr hMenu, uint uItem, bool fByPosition, System.IntPtr lpmii) -> bool
202-
static PInvoke.User32.SetWindowLongPtr(System.IntPtr hWnd, PInvoke.User32.WindowLongIndexFlags nIndex, System.IntPtr dwNewLong) -> System.IntPtr
203180
static PInvoke.User32.SetWindowLongPtr(System.IntPtr hWnd, PInvoke.User32.WindowLongIndexFlags nIndex, void* dwNewLong) -> void*
204-
static PInvoke.User32.SystemParametersInfoForDpi(PInvoke.User32.SystemParametersInfoAction uiAction, int uiParam, System.IntPtr pvParam, PInvoke.User32.SystemParametersInfoFlags fWinIni, int dpi) -> bool
205-
static PInvoke.User32.mouse_event(PInvoke.User32.mouse_eventFlags dwFlags, int dx, int dy, int dwData, System.IntPtr dwExtraInfo) -> void
206181
static extern PInvoke.User32.AdjustWindowRectEx(PInvoke.RECT* lpRect, PInvoke.User32.WindowStyles dwStyle, bool bMenu, PInvoke.User32.WindowStylesEx dwExStyle) -> bool
207182
static extern PInvoke.User32.AdjustWindowRectExForDpi(PInvoke.RECT* lpRect, PInvoke.User32.WindowStyles dwStyle, bool bMenu, PInvoke.User32.WindowStylesEx dwExStyle, int dpi) -> bool
208183
static extern PInvoke.User32.AreDpiAwarenessContextsEqual(System.IntPtr dpiContextA, System.IntPtr dpiContextB) -> bool
@@ -253,6 +228,7 @@ static extern PInvoke.User32.SetThreadDpiHostingBehavior(PInvoke.User32.DPI_HOST
253228
static extern PInvoke.User32.SetWindowText(System.IntPtr hWnd, string lpString) -> bool
254229
static extern PInvoke.User32.ShowCursor(bool bShow) -> int
255230
static extern PInvoke.User32.SystemParametersInfoForDpi(PInvoke.User32.SystemParametersInfoAction uiAction, int uiParam, void* pvParam, PInvoke.User32.SystemParametersInfoFlags fWinIni, int dpi) -> bool
231+
static extern PInvoke.User32.UnregisterClass(string lpClassName, System.IntPtr hInstance) -> bool
256232
static extern PInvoke.User32.mouse_event(PInvoke.User32.mouse_eventFlags dwFlags, int dx, int dy, int dwData, void* dwExtraInfo) -> void
257233
static readonly PInvoke.User32.DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE -> System.IntPtr
258234
static readonly PInvoke.User32.DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 -> System.IntPtr

src/User32/User32.cs

+21
Original file line numberDiff line numberDiff line change
@@ -1687,6 +1687,27 @@ public static extern unsafe int QueryDisplayConfig(
16871687
[return: MarshalAs(UnmanagedType.U2)]
16881688
public static extern short RegisterClassEx(ref WNDCLASSEX lpwcx);
16891689

1690+
/// <summary>
1691+
/// Unregisters a window class, freeing the memory required for the class.
1692+
/// </summary>
1693+
/// <param name="lpClassName">
1694+
/// A null-terminated string or a class atom. If lpClassName is a string, it specifies the window class name.
1695+
/// This class name must have been registered by a previous call to the <see cref="RegisterClass"/> or <see cref="RegisterClassEx"/> function.
1696+
/// System classes, such as dialog box controls, cannot be unregistered.
1697+
/// If this parameter is an atom, it must be a class atom created by a previous call to the <see cref="RegisterClass"/> or <see cref="RegisterClassEx"/> function.
1698+
/// The atom must be in the low-order word of lpClassName; the high-order word must be zero.
1699+
/// </param>
1700+
/// <param name="hInstance">A handle to the instance of the module that created the class.</param>
1701+
/// <returns>
1702+
/// If the function succeeds, the return value is nonzero.
1703+
/// If the class could not be found or if a window still exists that was created with the class, the return value is zero. To get extended error information, call <see cref="Marshal.GetLastWin32Error"/>.
1704+
/// </returns>
1705+
[DllImport(nameof(User32), SetLastError = true, CharSet = CharSet.Unicode)]
1706+
[return: MarshalAs(UnmanagedType.Bool)]
1707+
public static extern bool UnregisterClass(
1708+
string lpClassName,
1709+
IntPtr hInstance);
1710+
16901711
/// <summary>
16911712
/// Retrieves the name of the format from the clipboard.
16921713
/// </summary>

0 commit comments

Comments
 (0)