GetMenuString

  int GetMenuString(hmenu, idItem, lpsz, cchMax, fuFlags)    
  HMENU hmenu; /* handle of menu */
  UINT idItem; /* menu-item identifier */
  LPTSTR lpsz; /* address of buffer for string */
  int cchMax; /* maximum length of string */
  UINT fuFlags; /* menu flags */

The GetMenuString function copies the string of the specified menu item into the specified buffer.

Parameters

hmenu

Identifies the menu.

idItem

Specifies the menu item to be changed, as determined by the fuFlags parameter.

lpsz

Points to the buffer that is to receive the string.

cchMax

Specifies the maximum length, in characters, of the string to be copied. If the string is longer than the maximum specified in cchMax, the extra characters are truncated.

fuFlags

Specifies how the idItem parameter is interpreted. This parameter can be one of the following values:

Value Meaning

MF_BYCOMMAND The idItem parameter specifies the identifier of the menu item.
MF_BYPOSITION The idItem parameter specifies the zero-based relative position of the menu item.

Return Value

The return value specifies the number of characters copied to the buffer, not including the terminating null character.

Comments

The cchMax parameter should be the size of a null character (one for a Windows character, two for a Unicode character) larger than the number of characters in the string to accommodate the terminating null character.

The GetMenuString function may be used as either a wide-character function (where text arguments must use Unicode) or an ANSI function (where text arguments must use characters from the Windows 3.x character set).