Home  | Source Code  | Tools  | Links  | Search  |  
¿Habla Español?
Source Code Sections
ASP.NET General Internet Windows Explorer Windows Forms Old VB6 Code
shellextensions.zip (171Kb) 

Valid XHTML 1.0!

Valid CSS!

Shell Extensions with .NET

The code includes a library with base classes from which the extensions classes inherits. The base classes contains the code to register the extensions automatically (with the help of two custom attributes) when the extension library is registered for COM.

To create an extension, first create a COM Class and then using the Inherits keyword set the base class.

The Base Classes


This is the base class for Browser Helper Objects used by Internet Explorer. The class maps the methods and events of IE so you don't have to add the reference to shdocvw.dll in the project.


This is the base class for context menu handlers. Using the MenuItems collection you can add MenuItem objects to the context menu in the same way you do with a Windows Forms application.


DropHandlerBase is the base class for drop handler extensions. Override the OnDragXXXX methods to control what is being dropped. The Files property returns the names of the dragged files and the FileName property returns the name of the file where the files are dropped.


This one allows to create an icon handler. Override the OnExtractIcon and OnGetIconLocation methods to return the icon of the file pointed by the FileName property.


Use this class if you want to add a button to the toolbar or a menu item to the Tools menu of InternerExplorer. Using the custom IEMenuButtonType attribute you can set the button/menu text and icon. This class inherits from BrowserHelperObjectBase giving you access to the Internet Explorer instance from the class.


This is the base for InfoTip handlers. Override the OnGetInfoTip to provide your custom tooltip text for the registered file type.


A base class for property sheets extensions. After you create the class and set this as the base class you can open it in the Designer window to add controls to the page.


The ShellExecuteHookBase is used to create ShellExecute hook extensions.


This is the base class for thumbnail handlers. Override the GetImage function to return the thumbnail image for a file.

The custom attributes


This attribute is used to set the file types for which an extension has to be registered. To register a extension for several file types, separate the file types with a comma:


The following extensions require this attribute (registration won't fail if the attribute is omitted, but the extension will be useless):

  • Context menu handler
  • Drop handler
  • Icon handler
  • InfoTip handler
  • Property sheet handler
  • Thumbnail handler


This attribute is used only by the IEMenuButtonBase to know how to register the extension. For example, if you want to register the extension for a menu item:

<IEMenuButtonType(IEMenuButtonType.MenuItem, _
                  "Menu Item Text", _
                  StatusText:="This is the help line")>