开发者

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

I'm trying to display standard file/directory context menu in WinForms application - I'd like to enabl开发者_开发技巧e the user to do things with files in my application as he could in Explorer.

There should be two options

  • popup the context menu with some system call
  • read everything from the system context menu and insert it into my context menu

Could you please point me in the right direction? Thanks


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.

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

  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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜