DestroyMenu function (winuser.h)

Destroys the specified menu and frees any memory that the menu occupies.

Syntax

BOOL DestroyMenu(
  [in] HMENU hMenu
);

Parameters

[in] hMenu

Type: HMENU

A handle to the menu to be destroyed.

Return value

Type: BOOL

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.

Remarks

Before closing, an application must use the DestroyMenu function to destroy a menu not assigned to a window. A menu that is assigned to a window is automatically destroyed when the application closes.

DestroyMenu is recursive, that is, it will destroy the menu and all its submenus.

Examples

For an example, see Displaying a Shortcut Menu.

Requirements

Requirement Value
Minimum supported client Windows 2000 Professional [desktop apps only]
Minimum supported server Windows 2000 Server [desktop apps only]
Target Platform Windows
Header winuser.h (include Windows.h)
Library User32.lib
DLL User32.dll
API set ext-ms-win-ntuser-menu-l1-1-0 (introduced in Windows 8)

See also

Conceptual

CreateMenu

DeleteMenu

Menus

Reference

RemoveMenu

SetMenuItemInfo