IContextMenu3::InvokeCommand Method
Carries out the command associated with a shortcut menu item.
Syntax
HRESULT InvokeCommand( LPCMINVOKECOMMANDINFO pici );
Parameters
- pici
A pointer to a CMINVOKECOMMANDINFO or CMINVOKECOMMANDINFOEX structure containing information about the command. For further details, see the Remarks section.
Return Value
Returns S_OK if successful, or an error value otherwise.
Remarks
The IContextMenu interface is exported by several Shell extension handlers and namespace extensions to add commands to shortcut menus. When the user selects one of the commands that the handler or namespace extension added to a shortcut menu, the Shell calls its InvokeCommand method. The command can be specified by its menu identifier offset, defined when IContextMenu::QueryContextMenu was called, or by its associated verb. An application can invoke this method directly by obtaining a pointer to an object's IContextMenu interface. An application can also invoke this method indirectly by calling ShellExecute or ShellExecuteEx and specifying a verb that is supported by the namespace extension or handler.
If the verb, specified either by a canonical verb name or the command ID is not recognized by the context menu handler, it must return a failure (E_FAIL) to allow it to be passed on to the other context menu handlers that might implement that verb.
Although the pici parameter is declared in Shlobj.h as a CMINVOKECOMMANDINFO structure, in practice it often points to a CMINVOKECOMMANDINFOEX structure. This structure is an extended version of CMINVOKECOMMANDINFO and has several additional members that allow Unicode strings to be passed.
Note to Users
You can pass either structure to IContextMenu::InvokeCommand. Either will work for ANSI strings, but you must use a CMINVOKECOMMANDINFOEX structure for Unicode strings.
Note to Implementers
Check the cbSize member of pici to determine which structure was passed in. If it is a CMINVOKECOMMANDINFOEX structure and the fMask member has the
CMIC_MASK_UNICODEflag set, you must cast pici to CMINVOKECOMMANDINFOEX to use the Unicode information contained in the last five members of the structure.
See Also