Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I create my custom Shell Context Handlers for Windows?

Problem

Language: C# 2.0 or later


I would like to register context handlers to create menues when the user right clicks certain files (in my case *.eic). What is the procedure to register, unregister (clean up) and handle events (clicks) from these menues?

I have a clue it's something to do with the windows registry, but considering how much stuff there is in .net, I wouldn't be surprised if there are handy methods to do this clean and easy.

Code snippets, website references, comments are all good. Please toss them at me.

Update


Obviously there is a slight problem creating context menues in managed languages, as several users have commented. Is there any other preferred way of achieving the same behaviour, or should I spend time looking into these workarounds? I don't mind doing that at all, I'm glad people have put effort into making this possible - but I still want to know if there is a "proper/clean" way of achieving this.

like image 201
Statement Avatar asked Dec 08 '22 09:12

Statement


2 Answers

Resist writing Shell Extensions in managed languages - there are a multitude of things that could go bang if you pursue this route.

Have a browse through this thread for more details. It contains links to do it if really want, and sagely advice of why it can be done, but shouldn't.

http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/1428326d-7950-42b4-ad94-8e962124043e/

You're back to unmanaged C/C++ as your only real tools here.

like image 172
stephbu Avatar answered Dec 09 '22 22:12

stephbu


This is not a good idea because of potential dependency issues between different versions of the .NET Framework. Your shell extension could be expecting one version, while a different version may have already been loaded by the application that's currently running.

This thread contains a good summary of the situation.

like image 32
user20569 Avatar answered Dec 09 '22 22:12

user20569