Showing windows (file/directory) context menu in c# winforms application

I have written a .NET library to allow this. You can find it here:

http://gong-shell.sourceforge.net/

The class you're looking for is ShellContextMenu within that library.


This may prove to be very challenging, so I propose two solutions:

  1. (Easy) Using the library that Groky suggested, do what is done in FolderSizes. The Explorer context menu is shown as a sub-context-menu. You can simulate this by displaying the explorer menu when the "Explorer Operation" item is hovered.

    enter image description here

  2. (Hard) If that is insufficient, you can go all the way and get the menu items from the shell, and create your own menu. This CodeProject article ( http://www.codeproject.com/KB/miscctrl/FileBrowser.aspx ) goes through the process of enumerating and invoking shell commands for a specific shell object, and how to enumerate submenus.