5Jul/0716
Shell Context Menu
EDIT: There is a newer version here!
Some VB.NET 2005 code to display the Shell Context Menu for file system objects.
- Supports multiple files.
- Supports proper drawing of Open With and Send To menus.
- Supports Special Folders.
Any problems with the code or bug fixes please don't hesitate to complain.

July 16th, 2007 - 11:55
Thanks, I’ve been looking for this all over!
July 16th, 2007 - 12:01
Pleasure
July 16th, 2007 - 12:04
Thanks for the code!
September 30th, 2007 - 01:48
Hi
Fantastic code, just what I was after.
Is it possible to add custom items to the menu and return a result based on the custom item that was selected ?
A few pointers in the right direction would be extremely helpful.
Thanks again
Martin
September 30th, 2007 - 23:39
That’s totally possible, although I haven’t ever done it before.
I have seen numerous examples on codeproject etc.
They would only show up in menus that you show yourself though. There are plenty examples showing how to add an item to the default menu though. The most simple method is a registry hack.
December 1st, 2007 - 21:00
This piece of code is awesome! There were a lot of commercial ActiveX and OCX controls that did a lot more than just provide explorer context menu, but menu is the only thing I need.
Thank you!
December 2nd, 2007 - 10:42
Glad you found some use of it!
March 7th, 2008 - 22:26
Thank you for the code. It works like a charm.
Teo
March 10th, 2008 - 13:43
Glad it worked for you.
April 22nd, 2008 - 19:56
Any idea why the “Rename” option isn’t in the menu?
April 22nd, 2008 - 20:32
I think it’s something to do with some flags in one of the calls.
Please remind me of the problem if you find it, and I’ll update the code.
Otherwise, I’ll take a look tomorrow maybe.
April 22nd, 2008 - 21:43
Thanks for the pointer. In the call to QueryContext menu the uFlags parameter must have the CMF_CANRENAME bit (&H10 in VB) set for the Rename option to appear. Please not that code EXTERNAL to the code provided here must handle this by examining the return code.
On another note, there is something strange with the code that sets uFlags to 256 when a shift key is pressed. If I need to figure this out I’ll post again.
April 23rd, 2008 - 07:37
Yeah, you’re gonna have to take the return code and code a replacement for the rename dialog.
Not very good cause you’ll have to hard code Rename. Seems like a step backwards to me.
April 23rd, 2008 - 07:46
CMF_EXTENDEDVERBS
This flag is set when the calling application wants extended verbs. Normal verbs are displayed when the user right-clicks an object. To display extended verbs, the user must right-click while pressing the SHIFT key.
Got that from MSDN. Should have added a constant for that, sorry. Quite cryptic.
July 8th, 2009 - 16:38
is it possible to display the contextmenu, which appears by clicking in the empty space in windows-explorer?
January 24th, 2010 - 11:31
Thanks A Lot for the code…