IContextMenuProvider::AddItem method

The AddItem method adds a single item to a context menu.

Syntax

HRESULT AddItem(
  [in] CONTEXTMENUITEM *pItem
);

Parameters

  • pItem [in]
    A pointer to a CONTEXTMENUITEM structure with the item to be added. This parameter cannot be NULL.

Return value

The AddItem method returns one of the following values:

  • S_OK
    The menu item was successfully added.

  • E_UNEXPECTED
    An unexpected error occurred.

  • E_POINTER
    The pItem parameter is NULL.

  • E_INVALIDARG
    One or more of the following conditions occurred:

    • An item already exists with this lCommandID. See CONTEXTMENUITEM.
    • The insertion point identified by the lInsertionPointID member of CONTEXTMENUITEM could not be found.
    • The command ID (if you are adding a menu item) or insertion point ID (if you are adding a submenu or insertion point) identified by the lCommandID member of CONTEXTMENUITEM is invalid or cannot be used at this time. For example, snap-ins acting as context menu extensions cannot insert or reference a primary insertion point.
    • The fFlags member of CONTEXTMENUITEM contains MF_OWNERDRAW or MF_BITMAP.
    • An extension tried to add an item where either fFlags contains MF_SEPARATOR, or fSpecialFlags contains CCM_SPECIAL_SEPARATOR.
    • The strName member of CONTEXTMENUITEM is NULL and this is not a separator or insertion point.
    • The fSpecialFlags member of CONTEXTMENUITEM contains CCM_SPECIAL_SUBMENU, but fFlags does not contain MF_POPUP.

Requirements

Minimum supported client

Windows Vista

Minimum supported server

Windows Server 2008

Header

Mmc.h

DLL

Mmcndmgr.dll

See also

CONTEXTMENUITEM

IContextMenuProvider