首页  编辑  

how to pop up shell menu

Tags: /超级猛料/Stream.File.流、文件和目录/Shell操作/   Date Created:

how to pop up shell menu

Take a look at the interface IContextMenu. Here are the steps you need

to do:

- Get such an interface from a shell folder by calling

IShellFolder.GetUIObjectOf().

- Create a menu handle (use Windows.CreateMenu)

- Call IContextMenu.QueryContextMenu() passing the menu handle you

created so that the object populates the windows menu with all items.

- Use TrackPopupMenu() or TrackPopupMenuEx() to display the menu.

Specify the flag TPM_RETURNCMD so that the function returns the

command id of the item the user selected (typecast the result of

TrackPopupMenu to a DWORD).

- Use IContextMenu.InvokeCommand() to invoke the selected command id

on the shell object.