Reputation: 25197
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
Upvotes: 1
Views: 574
Reputation: 26800
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.
Upvotes: 1
Reputation: 159718
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.
Upvotes: 1
Reputation: 5367
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.
Upvotes: 2
Reputation: 2195
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
Upvotes: 1