开发者

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 it开发者_运维问答ems, my application's method should be called (similar to what WinRAR does)

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.

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. See here for a DDE example.

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. You can read about it here and see here for an example. You could also check out 3rd party libraries like ContextMenu.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜