10

Is there 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 programmatically.

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

How to programmatically execute Windows Explorer context menu items?

Cœur
  • 37,241
  • 25
  • 195
  • 267
jgraves
  • 477
  • 4
  • 9
  • This is one of those areas where "go look in the registry" may be an acceptable solution (the registry keys are part of the documented interface so it's not as naughty as it sounds). Have you tried that? Did it just result in further hair loss? – itowlson Jan 19 '10 at 04:33
  • Let me get more info about the question, u have a .net application that works on a specific type of files and you want a windows explorer context menu command that can run ur application and pass the file path (4 example) to it, is this ur intent? – Mostafa Elmoghazi Jan 19 '10 at 06:17
  • itowlson - I may have to use the registry, although it isn't as ideal as reading the commands directly. As mentioned in a comment below, going to the registry means missing out on certain menu items. SubPortal - No, that is not my intent at all. I want to read the context menu items of any file type and list them and let the user execute them programatically. – jgraves Jan 20 '10 at 01:03
  • [How to host an IContextMenu, part 1 – Initial foray - Raymond Chen - MSFT - September 20, 2004](https://blogs.msdn.microsoft.com/oldnewthing/20040920-00/?p=37823) – Cœur Jan 22 '19 at 06:34
  • http://www.maddogsw.com/cmdutils/ - follow "_download 124K cmdutils.zip_", extract it, extract CmdUtils-Source.zip, check the "context" folder for C++ source code from year 2000 using IContextMenu. – Cœur Jan 22 '19 at 06:39
  • The master of the shell, Raymond Chen, did a whole series of [posts](http://blogs.msdn.com/oldnewthing/archive/2004/09/20/231739.aspx) 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](http://web.archive.org/web/20070822122059/http://www.eluent.com/runmenu.htm), I'm sure you can find the .exe somewhere on the net) – Anders Jan 19 '10 at 20:34

0 Answers0