tags:

views:

164

answers:

4

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.

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.

EDIT:

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

+1  A: 

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%5Fcustom.html

Martin Blore
it's terrifying that the screenshots are using Win95 ;-) I'll look at it though thx
Nathan Koop
If it is for Win95, it probably doesn't work anymore for Vista/Seven... I noticed that 7-Zip shell integration, for instance, doesn't work on Seven.
Thomas Levesque
Woops, sorry, kinda late here and missed that ;) I just knew from old Win32 days that this stuff was done in the registry and hope you can research further in to where the keys lay for Vista/Seven :).
Martin Blore
+2  A: 

You need to use (Explorer) Shell Extensions. They are programmed with 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.

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

modosansreves
Thanks, I'm not terribly interesting in learning a lot about COM, but I'd be willing to do some reading into it, do you know of any good online examples?
Nathan Koop
http://lmgtfy.com/?q=Shell+extensions+tutorial
Ed Swangren
+1  A: 

They're called 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.

Shog9
+1  A: 

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.

Factor Mystic
Thanks I done a bit more research and have decided the technical cost to implement this feature within IE or word etc... is just too high. I have learned a lot about shell extensions, and will use those however in either this or my next project.
Nathan Koop