Search code examples
c#registrywindows-explorer

Edit Windows Context Menu in the C#


I would like a particular type of file (eg. Namefile.ext2) read all the names preceded by a #

Sample contents of the file:

#nameone
#nametwo
#namethree

When I click the right mouse button on the ext2 file extension beyond the standard options (like: open, properties, etc ...) I would like to be:

contents of the file > nameone

                       nametwo

                       namethree

Then, select the item (eg. nameone) pass this parameter to my program running in the background / or services

Do you need to modify the registry somehow? I will be grateful for tips on how to achieve the desired effect.


Solution

  • What you are asking about is called 'shell extension'. Basically it requires some knowledge of COM objects programming, but .NET made things a bit easier in that matter.

    Shortly: you have to develop a piece of code which will reads the file and generates menu items dynamically (which may be tricky but possible). That code needs to be registered in the system as COM object. Before it starts working you have to associate file extension with COM object you created.

    Perhaps this article can explaint it a bit more: http://www.codeproject.com/Articles/512956/NET-Shell-Extensions-Shell-Context-Menus