How to show system menu of a file in C#(如何在C#中显示文件的系统菜单)
问题描述
我需要在我的应用程序中显示文件的系统菜单.此菜单与图像相同.
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#中显示文件的系统菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在C#中显示文件的系统菜单
基础教程推荐
- 经典 Asp 中的 ResolveUrl/Url.Content 等效项 2022-01-01
- 错误“此流不支持搜索操作"在 C# 中 2022-01-01
- JSON.NET 中基于属性的类型解析 2022-01-01
- 将事件 TextChanged 分配给表单中的所有文本框 2022-01-01
- 从 VS 2017 .NET Core 项目的发布目录中排除文件 2022-01-01
- 全局 ASAX - 获取服务器名称 2022-01-01
- 首先创建代码,多对多,关联表中的附加字段 2022-01-01
- 在 VS2010 中的 Post Build 事件中将 bin 文件复制到物 2022-01-01
- 如何动态获取文本框中datagridview列的总和 2022-01-01
- 是否可以在 asp classic 和 asp.net 之间共享会话状态 2022-01-01
