Home > Articles > Programming > .NET and Windows Programming

Windows Shell Extensions in .NET

  • PrintPrint
  • Share ThisShare This
  • DiscussDiscuss
Windows Shell Programming

Like this article? We recommend
Windows Shell Programming

Wouldn't it be great if you could add your favorite tools right into the Windows Shell? And wouldn't it be great if you could do it from .NET? The good news is that you can! Shawn Wildermuth shows you how in this discussion of Windows Shell Extensions in .NET.

Like most of the developers out in the world, I have a bag of tools that I have developed over the years. In the old days, these tools usually took the form of command-line utilities to do a myriad of different tasks. As time wears on, I spend less and less of my time at a command line. I still need these tools, but it would be really useful if I could integrate them into the Windows environment.

Understanding Shell Extension Handlers

The Windows Explorer is a wonderful little tool. It may look like just a typical file/folder viewer, but it is actually a bit more simplistic than that: The Windows Explorer is just an application that exposes the Windows Shell. The view of the file system is called the Windows Shell. You will see the same behavior all around Windows; file dialogs, Internet Explorer's FTP view, and more.

Luckily for us, Microsoft has created a way to hook into the Shell to add our own functionality. There are different types of Shell Extensions that we can create. Some of the handlers are based on the type of file the user is looking at (see Table 1).

Table 1. File-based Shell Extension Types

File Handlers

Description

Shortcut menu

Adds items to the popup menu for specific files extensions.

Data handler

Handles data when Shell objects are dragged and dropped.

Drop handler

Makes a file become a drop target for a specific type of file.

Icon handler

Allows overriding of the icon for types of files.

Property sheet

Allows you to add or replace pages in an object's property sheet.

Thumbnail image

Allows you to specify the image to use for a thumbnail image.

Infotip handler

Allows you to specify the text for the popup infotip.

Metadata handler

Allows you to change or extend the metadata about specific file types.


Other extensions are based on the operation that the user is attempting to do in the Shell, as shown in Table 2.

Table 2. Operation-based Handlers

Operation Handlers

Description

Column handler

Allows you to add or replace columns displayed in the details view of a folder.

Copy hook

Allows you to intercept a copy operation to do specific operations.

Drag-and-drop

Allows you to modify the drag-n-drop popup menu.

Icon overlay

Allows you to specify an overlay for icons.

Search handler

Allows you to implement specific search types.


For this article, we will create a simple Shortcut Menu Handler. The handler will show up only when the user opens a folder's popup menu, as shown in Figure 1.

Figure 1Figure 1 Our shell extension.

Our extension will look at a folder (and all its subfolders) and clean any temporary files. But how will it work?

  • Share ThisShare This
  • Your Account

Discussions

Make a New Comment

You must log in in order to post a comment.

Related Resources

Jennifer  BortelWin FREE iPhone Developer Books and Videos- Introducing @InformIT Giveaways
By Jennifer Bortel on February 5, 2010 No Comments

Apples’s recent iPad announcement made our hearts flutter so we couldn’t resist making an announcement of our own!

Today marks the first ever @InformIT Giveaway!

We’ll regularly post a video like this one profiling spectacular prizes we’re giving away—from books and videos to T-shirts and other exciting stuff. Check out the video below to see the giveaways for today, and then scroll down for more prize details and instructions on how to win them!

Dustin Sullivan"Every OSX developer should have this book on their desk."
By Dustin Sullivan on February 1, 2010 No Comments

That was the sentence Mike Riley ended his recent Dr Dobb's CodeTalk review of Cocoa Programming Developer's Handbook with.

David ChisnallCocoa Tip of the Day, 1/29/10
By David Chisnall on January 29, 2010 No Comments

Don't ignore old versions of OS X.

See All Related Blogs

Informit Network