问题描述
我需要在我的应用程序中显示文件的系统菜单.此菜单与图像相同.
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.