如何从 C# 应用程序显示 Windows 资源管理器上下文菜单?
我的应用程序中有一个文件列表,我希望允许人们右键单击某个项目并显示 Windows 资源管理器上下文菜单。 我假设我需要使用 IContextMenu 接口,但我不太确定从哪里开始。
I have a file listing in my application and I would like to allow people to right-click on an item and show the Windows Explorer context menu. I'm assuming I would need to use the IContextMenu interface, but I'm not really sure where to start.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我写了一个库,也许可以帮助你。 您可以使用库提供的控件,或者如果您不想这样做,查看代码可能会给您答案。
您可以在以下位置找到该库: http://gong-shell.sourceforge.net/
请让我知道这是否有帮助!
I have written a library that might be able to help you. You could use the controls provided by the library, or if you don't want to do that, looking through the code may give you an answer.
You can find the library at: http://gong-shell.sourceforge.net/
Please let me know if this helped!
Raymond Chen 的博客上有一个关于托管 IContextMenu 的非常好的教程(尽管是用 C++ 编写的),分为 11 个部分(按顺序):
There's a very good tutorial (albeit in C++) about hosting an IContextMenu on Raymond Chen's blog in 11 parts (in order):
我发现了一篇很棒的代码项目文章,它将所有内容很好地封装到一个类中!
Explorer Shell 上下文菜单
就像下面的代码片段一样简单:
唯一令人厌烦的事情是它需要一个 FileInfo[] 数组或一个 DirectoryInfo[] 数组,尽管很容易稍微修改源代码,以便它需要一个 FileSystemInfo[] 数组
I found a great Code Project article that encapsulates everything very nicely into one class!
Explorer Shell Context Menu
It's as easy as the following code snippet:
The only irksome thing is that it takes either an array of FileInfo[] or an array of DirectoryInfo[] although it was VERY easy to modify the source slightly so that it would take an array of FileSystemInfo[]