A version of this page is also available for

Windows Embedded CE 6.0 R3


This function invokes a command from a context menu. It issues the command in the extension that added it to the menu.


BOOL SHInvokeContextMenuCommand(
  HWND hwndOwner,
  UINT idCmd,
  HANDLE hCMExtensions


  • hwndOwner
    [in] Handle to the window that owns the menu, message boxes, and so on.
  • idCmd
    [in] Command ID to execute.
  • hCMExtensions
    [in] Handle to the context menu extensions abstraction object.

Return Value

This function returns TRUE if it is successful and FALSE if it fails.


The extension will usually have at its disposal an abstraction interface from the application that it can use to obtain application-specific information. This will help make the extension more flexible and powerful. If an application abstraction is available, the shell will set it to the site of the extension using IObjectWithSite::SetSite. The extension should implement IObjectWithSite::SetSite.

Thus, when the user chooses a command from the extended menu and the application calls SHInvokeContextMenuCommand,which in turn calls IContextMenu::InvokeCommand, the extension can get a reference to the app abstraction interface by calling IObjectWithSite::GetSite.


Header aygshell.h
Library aygshell.lib
Windows Embedded CE Windows CE 3.0 and later
Windows Mobile Pocket PC 2000 and later

See Also