添加物品到右键菜单右键菜单、物品

2023-09-04 05:18:02 作者:丿sa灬羽化恋佳

我想将项目添加到右键菜单(如TortoiseSVN做的,或者7zip的等...)

I'd like to add an item into the right click menu (like TortoiseSVN does, or 7zip etc...)

我不知道如何做到这一点,或它是什么特别要求。

I'm not sure how to do this or what it is specifically called.

这将是preferable如果在我的程序运行此选项是唯一可用的。

It would be preferable if this option was only available while my program was running.

使用情况:

用户将选择在网页上(他们的计算机上或Word文档或任何东西)一些文本,点击右键,从菜单中选择我的项目,我分DoSomething的(字符串MyString的)会跑。

User would select some text on a webpage (or word document or anything on their computer) and right click, select my item from menu and my sub DoSomething(string myString) would run.

编辑:

我目前正在开发的XP,但我想这个节目的工作在Vista / Win7的

I'm currently developing on XP, but I'd like this program to work on Vista/Win7

推荐答案

这要看你想上哪儿上下文菜单项目和什么总体目标。大部分的答案至今是在资源管理器右键菜单,但如果你想改变一个程序作为你的问题国家内部的上下文菜单,它变得更加困难和/或不可能的。

It depends on where you want the context menu items and for what overall purpose. Most of the answers so far are for context menus in Explorer, but if you want to change a context menu inside of a program as your question states, it becomes much harder and/or impossible.

但是,它很可能添加上下文菜单项到文件的浏览器类型,而外壳扩展,它可以通过的注册表操作或第三方公用事业的,或与COM作为其他人说。

However, it's very possible to add context menu items to file types in explorer without shell extensions, it's possible by registry manipulation or 3rd party utilities, or with COM as others have said.