将项目添加到右键菜单

时间:2021-01-30 07:31:55

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

我想在右键菜单中添加一个项目(如TortoiseSVN,或7zip等...)

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

我不确定如何做到这一点或它的具体名称。

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

如果此选项仅在我的程序运行时可用,那将是更好的选择。

Use case:

使用案例:

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.

用户将在网页上选择一些文本(或word文档或其计算机上的任何内容)并右键单击,从菜单中选择我的项目并运行我的子DoSomething(字符串myString)。

EDIT:

编辑:

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

我目前正在开发XP,但我希望这个程序可以在Vista / Win7上运行

4 个解决方案

#1


1  

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.

这取决于您希望上下文菜单项的位置以及总体目的。到目前为止,大多数答案都是针对资源管理器中的上下文菜单,但如果您想在问题中更改程序内部的上下文菜单,则会变得更加困难和/或不可能。

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.

但是,很有可能在没有shell扩展的情况下将上下文菜单项添加到资源管理器中的文件类型,可以通过注册表操作或第三方实用程序,或者像其他人所说的那样使用COM。

#2


2  

You need to use (Explorer) Shell Extensions. They are programmed with COM.

您需要使用(Explorer)Shell Extensions。它们用COM编程。

COM is essential for non-managed programming. So, if you want to know lots about how Windows works, get a book and learn it. Adding items to a menu will be an example there.

COM对于非托管编程至关重要。所以,如果你想了解很多关于Windows如何工作的知识,那就买一本书然后学习它。将项目添加到菜单就是一个例子。

There might be .Net wrappers for what you want, but I'm not aware of them yet.

你可能会有.Net包装器,但我还没有意识到它们。

#3


1  

I believe this can be achieved by adding/removing entries in the system registry.

我相信这可以通过添加/删除系统注册表中的条目来实现。

A practical example can be found here: http://www.jfitz.com/tips/rclick_custom.html

可以在这里找到一个实际的例子:http://www.jfitz.com/tips/rclick_custom.html

#4


1  

They're called Shell Extensions.

它们被称为Shell Extensions。

Well, sorta - shell extensions can do a whole lot more than just modify context menus, but if you want to do anything non-trivial with the menus then you'll want to write a shell extension.

好吧,sorta - shell扩展可以做很多事情,而不仅仅是修改上下文菜单,但是如果你想对菜单做任何不重要的事情,那么你将要编写一个shell扩展。

#1


1  

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.

这取决于您希望上下文菜单项的位置以及总体目的。到目前为止,大多数答案都是针对资源管理器中的上下文菜单,但如果您想在问题中更改程序内部的上下文菜单,则会变得更加困难和/或不可能。

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.

但是,很有可能在没有shell扩展的情况下将上下文菜单项添加到资源管理器中的文件类型,可以通过注册表操作或第三方实用程序,或者像其他人所说的那样使用COM。

#2


2  

You need to use (Explorer) Shell Extensions. They are programmed with COM.

您需要使用(Explorer)Shell Extensions。它们用COM编程。

COM is essential for non-managed programming. So, if you want to know lots about how Windows works, get a book and learn it. Adding items to a menu will be an example there.

COM对于非托管编程至关重要。所以,如果你想了解很多关于Windows如何工作的知识,那就买一本书然后学习它。将项目添加到菜单就是一个例子。

There might be .Net wrappers for what you want, but I'm not aware of them yet.

你可能会有.Net包装器,但我还没有意识到它们。

#3


1  

I believe this can be achieved by adding/removing entries in the system registry.

我相信这可以通过添加/删除系统注册表中的条目来实现。

A practical example can be found here: http://www.jfitz.com/tips/rclick_custom.html

可以在这里找到一个实际的例子:http://www.jfitz.com/tips/rclick_custom.html

#4


1  

They're called Shell Extensions.

它们被称为Shell Extensions。

Well, sorta - shell extensions can do a whole lot more than just modify context menus, but if you want to do anything non-trivial with the menus then you'll want to write a shell extension.

好吧,sorta - shell扩展可以做很多事情,而不仅仅是修改上下文菜单,但是如果你想对菜单做任何不重要的事情,那么你将要编写一个shell扩展。