I want to add a context menu option for deeper integration of one of my programs. However, I hate when I have 20+ items in this heavily used menu - so I wont make my end user endure this as well.
I know the context menu can be customized by file type, but Tortoisegit is able to customized generic folders.
Tortoisegit is some how able to detect when the context menu is opened in a folder controlled by Tortoisegit and display a different menu with additional items.
How is this done? Is this done by Tortoisegit somehow running in the background, or a registry setting for context menus, or something else?
It is done with a registry setting. Run regedit.exe and navigate to
HKCR\Folder\shellex\ContextMenuHandlers
. You'll find the CLSID for Tortoise in that list. TheHKCR\*
registry key is similarly special, it works for any file.Writing shell extensions in C# is strongly discouraged, failure to inject the CLR into a process is undiagnosable.