views:

234

answers:

4

I'm about to tear my hair out for lack of a consistent, foolproof way to get at the context menu items that Explorer shows when I right click on an item. I don't want to show a menu, I just want to parse the items in the background and execute them programatically.

I've tried various combinations of IShellFolder, IContextMenu, and other COM interfaces and I cannot find anything that works consistently.

I realize this is a vague question, but if anyone has any experience at all in the arena of programatically executing Windows Explorer context menu items, any help would be appreciated.

A: 

The closest thing I could find is http://oreillynet.com/pub/a/network/excerpt/winxphacks_chap1/index1.html which describes the registry settings that correspond to the right click menu.

George Edison
It is IMPOSSIBLE to enumerate the context menu entries by just looking in the registry, you miss all the entries created by shell extensions (The shell extension could decide at run-time based on the time of day what menu items it wants to add etc)
Anders
I know. That's why I said "closest".
George Edison
A: 

The master of the shell, Raymond Chen, did a whole series of posts about IContextMenu on his excellent blog.

There is also a little freeware app called Runmenu that will execute items from the shell context menu directly (The website seems to be down, I'm sure you can find the .exe somewhere on the net)

Anders
I've been through the Raymond Chen posts before and they are quite helpful, but still not clearing up some of the quirky behavior I'm seeing.That Runmenu app looks great. I'm going to try emailing the author to see if I can get a bit of help.The part of my situation that makes this even harder is that I'm trying to do this from C#.
jgraves
+1  A: 

Found some interesting examples of invoking shell menu commands at Google Code Search

Sheng Jiang 蒋晟
oh wow, I never even thought about using google's code search. there's some really helpful stuff in there. thanks!
jgraves
+1  A: 

It took me like an hour to find RunMenu so I'll save time for everyone else trying to find it. Here's the link I found, version is 2.2:

http://www.programbits.co.uk/downloads/runmenu.zip

Hope it helps.

Jorge Vargas