adding my program to right-click menu

Foresp picture Foresp · May 30, 2011 · Viewed 10.3k times · Source

with right click menu, I mean this: I dont really know what its called, but i hope its right click menu.

When I google for queries like title of this question, i get nothing. some tutorials that shows how can i add an .exe to that list etc. but I'm looking for some tutorial that will teach me how to handle that data, what that right click menu will return me, etc. But sadly, I found nothing. So here I am, asking...

How can I add my program to that list, and when I do what it returns to me, are there any tutorial for this on the internet ?

Answer

Jan-Peter Vos picture Jan-Peter Vos · May 30, 2011

You would add some keys to the registry to have your program in that list. You can find more about it here: http://www.howtogeek.com/howto/windows-vista/add-open-with-notepad-to-the-context-menu-for-all-files/

In the example they use Notepad.exe %1 that will basicly do the same as calling Notepad.exe c:\myFile.txt from the run window.

You can read the parameter in the main(string[] args) method. It will pass it as contents of the args parameter. You can also get that value anywhere else in your application using the Environment.GetCommandLineArgs() method.

Please note that you should use Notepad.exe "%1" if the file you right-click on has spaces in its fullname, otherwise the fullname will be split into the args[i].