简体   繁体   English

将项添加到上下文菜单以及这些项的自定义操作

[英]Adding items to context menu and custom actions for these items

How can I add menu items to the Context menu for folders? 如何将菜单项添加到文件夹的“上下文”菜单中? I don't want to do this via registry. 我不想通过注册表这样做。 I want to integrate this with my application's installer and when the application is installed, the context menu items should be added. 我想将它与我的应用程序的安装程序集成,并且在安装应用程序时,应添加上下文菜单项。 On clicking the items, my application's method should be called (similar to what WinRAR does) 在单击项目时,应调用我的应用程序的方法(类似于WinRAR所做的)

Thanks. 谢谢。

There are two ways to add items to the context menu. 有两种方法可以将项添加到上下文菜单中。 I'm not sure why you don't want to use the registry, because it is the easiest method. 我不确定为什么你不想使用注册表,因为它是最简单的方法。 And you can have your installer automatically add or remove the registry keys if you want. 如果需要,您可以让安装程序自动添加或删除注册表项。 Both will use the registry anyway, since registering a Shell Extension involves adding registry keys. 无论如何,两者都将使用注册表,因为注册Shell扩展涉及添加注册表项。

Registry 注册处

This method is easy since it comes down to adding some registry keys. 这个方法很简单,因为它归结为添加一些注册表项。 The downside is that you can't put any logic in it. 缺点是你不能在其中加入任何逻辑。 You can read about it here . 你可以在这里阅读它。 You get a bit more control if you are using DDE to execute the menu items. 如果使用DDE执行菜单项,则可以获得更多控制权。 See here for a DDE example. 请参阅此处获取DDE示例。

Shell Extension 壳扩展

This method is a bit more work, but you can completely control the context menu from code. 此方法稍微有点工作,但您可以从代码中完全控制上下文菜单。 You would have to write a DLL, implement IContextMenu (or others) and register the dll with Windows Explorer. 您必须编写DLL,实现IContextMenu (或其他)并使用Windows资源管理器注册dll。 You can read about it here and see here for an example. 你可以在这里阅读它 这里看一个例子。 You could also check out 3rd party libraries like ContextMenu . 您还可以查看像ContextMenu这样的第三方库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM