LoadMenuW function (winuser.h)

Loads the specified menu resource from the executable (.exe) file associated with an application instance.

Syntax

HMENU LoadMenuW(
  [in, optional] HINSTANCE hInstance,
  [in]           LPCWSTR   lpMenuName
);

Parameters

[in, optional] hInstance

Type: HINSTANCE

A handle to the module containing the menu resource to be loaded.

[in] lpMenuName

Type: LPCTSTR

The name of the menu resource. Alternatively, this parameter can consist of the resource identifier in the low-order word and zero in the high-order word. To create this value, use the MAKEINTRESOURCE macro.

Return value

Type: HMENU

If the function succeeds, the return value is a handle to the menu resource.

If the function fails, the return value is NULL. To get extended error information, call GetLastError.

Remarks

The DestroyMenu function is used, before an application closes, to destroy the menu and free memory that the loaded menu occupied.

Examples

For an example, see Displaying a Shortcut Menu

Note

The winuser.h header defines LoadMenu as an alias which automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for Function Prototypes.

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-3 (introduced in Windows 10, version 10.0.14393)

See also

Conceptual

LoadMenuIndirect

MAKEINTRESOURCE

Menus

Reference