AndrewVos.Com .NET, C#, jQuery etc.

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.

Source code is here

Shell Context Menu

Filed under: Projects Leave a comment
Comments (16) Trackbacks (0)
  1. Thanks, I’ve been looking for this all over!

  2. Thanks for the code!

  3. 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

  4. 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.

  5. 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!

  6. Thank you for the code. It works like a charm.

    Teo

  7. Any idea why the “Rename” option isn’t in the menu?

    • 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.

  8. 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.

    • 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.

    • 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.

  9. is it possible to display the contextmenu, which appears by clicking in the empty space in windows-explorer?

  10. Thanks A Lot for the code…


Leave a comment


*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word

No trackbacks yet.