GetMenuString

Syntax

int GetMenuString(hMenu,wIDItem,lpString,nMaxCount,wFlag)

This function copies the label of the specified menu item into the lpString parameter.

Parameter Type/Description  
hMenu HMENU Identifies the menu.  
wIDItem WORD Specifies the integer identifier of the menu item (from the resource file) or the offset of the menu item in the menu, depending on the value of the wFlag parameter.  
lpString LPSTR Points to the buffer that is to receive the label.  
nMaxCount int Specifies the maximum length of the label to be copied. If the label is longer than the maximum specified in nMaxCount, the extra characters are truncated.  
wFlag WORD Specifies the nature of the wID parameter. If wFlags contains MF_BYPOSITION, wId specifies a (zero-based) relative position; if the wFlags parameter contains MF_BYCOMMAND, wId specifies the item ID.  

Return Value

The return value specifies the actual number of bytes copied to the buffer.

Comments

The nMaxCount parameter should be one larger than the number of characters in the label to accommodate the null character that terminates a string.