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.

Popularity: 20% [?]
Posted in Code Projects










2007-07-16 11:55:59
Thanks, I’ve been looking for this all over!
2007-07-16 12:01:27
Pleasure
2007-07-16 12:04:28
Thanks for the code!
2007-09-30 01:48:11
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
2007-09-30 23:39:49
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.
2007-12-01 21:00:49
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!
2007-12-02 10:42:28
Glad you found some use of it!
2008-03-07 22:26:58
Thank you for the code. It works like a charm.
Teo
2008-03-10 13:43:36
Glad it worked for you.
2008-04-22 19:56:24
Any idea why the “Rename” option isn’t in the menu?
2008-04-22 20:32:18
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.
2008-04-22 21:43:35
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.
2008-04-23 07:37:13
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.
2008-04-23 07:46:14
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.
2009-07-08 16:38:01
is it possible to display the contextmenu, which appears by clicking in the empty space in windows-explorer?
2010-01-24 11:31:02
Thanks A Lot for the code…