IContextMenu 

The IContextMenu interface is used to either create or merge a context menu associated with a certain object.

Default context menus are available for most objects that are visible within the Explorer s name space, such as files, folders, and printer objects. System-provided context menus are adaptable to file objects of any type, provided you have made the appropriate registry entries.

When to Implement

Implement IContexMenu in the following situations:

    To add dynamic menu items to a context menu associated with an object in the shell s name space. Implementation is accomplished by means of a handler located within an COM in-process server DLL.

    To allow menu items to be dynamically added to non-default drag-and-drop menus. Implementation is accomplished by means of a handler.

    Applications may either create or merge context menus of items in the shell  name space (or extended name space). This is accomplished by an application calling IContextMenu using IShellFolder::GetUIObjectOf_6HHGI.

    A namespace extension should implement IContextMenu so that either the shell or another application can access context menus belonging to items in its own name space. This is accomplished by using IShellFolder::GetUIObjectOf.

 

Shell extensions based on this interface must be initialized by using the IShellExtInit interface and menu items can be inserted by using either the InsertMenu1O2J7N8 or InsertMenuItem4GM3_TZ functions.

Also of note is that shell extensions do not work unless all appropriate registry entries are made.

When to Use

You don t call this interface directly. It is called by the shell when a user selects a context menu item that has been added by a handler registered under the appropriate registry keys, or when an application includes it as the riid parameter in a call to IShellFolder::GetUIObjectOf.

Methods in Vtable Order

IUnknown Methods

Description

QueryInterface2Y54585

Returns pointers to supported interfaces.

AddRef1SHW0SS

Increments reference count.

ReleaseDUW01A

Decrements reference count.

 

IContextMenu Methods

Description

QueryContextMenuM5CU4_

Adds commands to a context menu.

InvokeCommand1L08XT3

Carries out a menu command, either in response to user input or otherwise. For an example, see IExtractIcon5338SX.

GetCommandString0CX4HR

Retrieves the language-independent name of a menu command or the help text for a menu command.