Editar

Compartilhar via


GetMenuItemInfoW function (winuser.h)

Retrieves information about a menu item.

Syntax

BOOL GetMenuItemInfoW(
  [in]      HMENU           hmenu,
  [in]      UINT            item,
  [in]      BOOL            fByPosition,
  [in, out] LPMENUITEMINFOW lpmii
);

Parameters

[in] hmenu

Type: HMENU

A handle to the menu that contains the menu item.

[in] item

Type: UINT

The identifier or position of the menu item to get information about. The meaning of this parameter depends on the value of fByPosition.

[in] fByPosition

Type: BOOL

The meaning of uItem. If this parameter is FALSE, uItem is a menu item identifier. Otherwise, it is a menu item position. See Accessing Menu Items Programmatically for more information.

[in, out] lpmii

Type: LPMENUITEMINFO

A pointer to a MENUITEMINFO structure that specifies the information to retrieve and receives information about the menu item. Note that you must set the cbSize member to sizeof(MENUITEMINFO) before calling this function.

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, use the GetLastError function.

Remarks

To retrieve a menu item of type MFT_STRING, first find the size of the string by setting the dwTypeData member of MENUITEMINFO to NULL and then calling GetMenuItemInfo. The value of cch+1 is the size needed. Then allocate a buffer of this size, place the pointer to the buffer in dwTypeData, increment cch by one, and then call GetMenuItemInfo once again to fill the buffer with the string.

If the retrieved menu item is of some other type, then GetMenuItemInfo sets the dwTypeData member to a value whose type is specified by the fTypefType member and sets cch to 0.

Examples

For an example, see Example of Owner-Drawn Menu Items.

Note

The winuser.h header defines GetMenuItemInfo 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

Menus

Reference

SetMenuItemInfo