如何在C#中显示文件的系统菜单
- 作者: 电脑城出口基地
- 来源: 51数据库
- 2022-10-20
问题描述
我需要在我的应用程序中显示文件的系统菜单.此菜单与图像相同.
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#通过fleck实现wss协议的WebSocket多人Web实时聊天(附源码)
- 团队城市未满足要求:MSBuildTools12.0_x86_Path 存在
- 使用 MSBuild.exe 在发布模式下构建 C# 解决方案
- 当我发布 Web 应用程序时,AfterPublish 脚本不运行
- 构建时 T4 转换的产品仅在下一个构建中使用
- ASP.NET Core Application (.NET Framework) for Windows x64 only error in project.assets.json
- 新的 .csproj 格式 - 如何将整个目录指定为“链接文件"到子目录?
- 如何将条件编译符号(DefineConstants)传递给 msbuild
- MSBuild 支持 Visual Studio 2017 RTM 中的 T4 模板
- NuGet 包还原找不到包,没有源
