Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows Shell Integration using .NET

Tags:

c#

.net

windows

What's the easiest/best way to register your program in explorers right-click menu using .NET and C#?
i.e. I would like to be able to right-click on an item in windows explorer and get a "Edit with MyProgram"

This is the closest thing to a tutorial I could find but it mostly just dips into Win32 from .NET and is also outdated. How should this be done now?

like image 275
prestomation Avatar asked Jan 13 '09 04:01

prestomation


1 Answers

If you just want to add menu items, then a shell extension is overkill. You can register a command line in the registry which will run your exe with the selected file(s) as the parameter. Shell extensions are really only required if you want to change explorer's behavior, add custom icons, or hook shell based file operations.

http://www.codeproject.com/KB/shell/SimpleContextMenu.aspx

If a shell extension is what you need, you're best writing a thin wrapper in unmanaged code that calls out to another process that is your .NET application through some sort of cross process communication channel. Due to all the potential versioning issues, it's not recommended to load the .NET runtime into the explorer process.

like image 138
JD Conley Avatar answered Oct 14 '22 00:10

JD Conley