在 C# winforms 应用程序中显示窗口(文件/目录)上下文菜单

发布于 2024-08-28 00:27:35 字数 196 浏览 2 评论 0原文

我正在尝试在 WinForms 应用程序中显示标准文件/目录上下文菜单 - 我想让用户能够像在资源管理器中一样对我的应用程序中的文件执行操作。

应该有两个选项

  • 上下文菜单中
  • 弹出,其中一些系统调用从系统上下文菜单中读取所有内容并将其插入到我的上下文菜单中,

您能指出我正确的方向吗?谢谢

I'm trying to display standard file/directory context menu in WinForms application - I'd like to enable the user to do things with files in my application as he could in Explorer.

There should be two options

  • popup the context menu with some system call
  • read everything from the system context menu and insert it into my context menu

Could you please point me in the right direction? Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

善良天后 2024-09-04 00:27:35

我已经编写了一个 .NET 库来实现这一点。您可以在这里找到它:

http://gong-shell.sourceforge.net/

您的课程正在寻找的是该库中的 ShellContextMenu。

I have written a .NET library to allow this. You can find it here:

http://gong-shell.sourceforge.net/

The class you're looking for is ShellContextMenu within that library.

梦醒灬来后我 2024-09-04 00:27:35

这可能被证明是非常具有挑战性的,所以我提出了两种解决方案:

  1. (简单)使用 Groky 建议的库,执行 FolderSizes 资源管理器上下文菜单显示为子上下文菜单。您可以通过在“资源管理器操作”项悬停时显示资源管理器菜单来模拟这一点。

    在此处输入图像描述

  2. (困难) 如果这还不够,您可以一路走下去,从 shell 中获取菜单项,并创建您自己的菜单。这篇 CodeProject 文章 ( http://www.codeproject.com/KB/miscctrl/FileBrowser.aspx )详细介绍了为特定 shell 对象枚举和调用 shell 命令的过程,以及如何枚举子菜单。

This may prove to be very challenging, so I propose two solutions:

  1. (Easy) Using the library that Groky suggested, do what is done in FolderSizes. The Explorer context menu is shown as a sub-context-menu. You can simulate this by displaying the explorer menu when the "Explorer Operation" item is hovered.

    enter image description here

  2. (Hard) If that is insufficient, you can go all the way and get the menu items from the shell, and create your own menu. This CodeProject article ( http://www.codeproject.com/KB/miscctrl/FileBrowser.aspx ) goes through the process of enumerating and invoking shell commands for a specific shell object, and how to enumerate submenus.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文