我需要在我的应用程序中显示文件的系统菜单.此菜单与图像相同.
I need to show system menu of a file in my application. This menu same as the image.
而且,我还想在这个菜单中添加一个我的菜单元素.
And, I also want to add a my menu element to this menu.
我该怎么办?
谢谢
您要查找的内容称为 shell 上下文菜单.要在您的应用程序中显示这样的菜单,您必须调用 Windows API.这一点都不容易,但幸运的是,其他人已经尝试了它.
What you're looking for is called a shell context menu. To display such a menu in your application, you'll have to call the Windows API. This is not at all easy, but fortunately for you some other people have taken a stab at it.
CodeProject 上的 C# 文件浏览器 有一个 shell 上下文菜单,在那篇文章中也有描述.
The C# File Browser on CodeProject has a shell context menu, which is also described in that article.
然后 Andreas Johansson 从该项目中提取 shell 上下文菜单代码并将其上传为一个单独的 ZIP 文件,您可以此处下载.
Then Andreas Johansson extracted the shell context menu code from that project and uploaded it as a separate ZIP file, which you can download here.
我不知道如何使用它,甚至不知道它是否有效.这留给读者作为练习.但是如果你深入研究代码,你可以从中学到很多东西.
I have no idea how to use it, or even if it works. That's left as an exercise for the reader. But there is a lot you can learn from this if you dig into the code.
这篇关于如何在C#中显示文件的系统菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!