Windows Programming Custom Desktop File/Folder context menu extensions Using ShellSharp


When you need multi level menus, with multiple parameters SharpShell comes to rescue. has umpteen number of examples and it works perfect even for single level to multi level custom context menus.

Key thing is to create class with attributes [ComVisible(true)] and [COMServerAssociation(AssociationType.AllFiles)] and inheriting class fromSharpContextMenu which implements CanShowMenu and CreateMenu functions and you need to register the assembly via regasm tool or ServerRegistrationManager that Sharpshell creator recommends

public class AdvancedContextMenu : SharpContextMenu
    protected override bool CanShowMenu()
        //  We can show the item only for a single selection.
    protected override ContextMenuStrip CreateMenu()
        //  Create the menu strip.
        var menu = new ContextMenuStrip();
        ... add any level of ToolStripMenuItems and add them to menu
        return menu

More details can be obtained at and