Organization of This Book

This book is loosely divided into four parts. Even though each chapter contains a distinct project, many chapters build on knowledge gained from previous chapters. So, really, the book is best read in the order in which the chapters were written. But don’t worry. If you just have to skip ahead to Chapter 10, to find out how to write an InfoTip handler, you can do that, too. Any information you might need from previous chapters is referenced. Here’s how the book breaks down:

Part I

Part I includes Chapter 1, Chapter 2, and Chapter 3. These chapters are designed to introduce you to the basics of the Windows shell and to provide a jumpstart on the Component Object Model and how it relates to writing in-process components for Visual Basic.

Part II

Part II includes Chapter 4 through Chapter 10. In these seven chapters, we will write seven shell extensions. These chapters are centered around a mythical file type (called a .rad file), which contains simple data about animals. Although the focus of these projects centers around a make-believe file type, these chapters are designed to show you the most effective ways to build shell extensions for your own data.

In these chapters we will write the following projects:

Context menu handler

Context menus are the menus that appear when you right-click on a file. Context menu handlers allow you to add your own items (and the code to carry out the commands) to this menu. Context menu handlers are discussed in Chapter 4.

Drag-and-drop handler

These are similar to context menu handlers. Drag-and-drop handlers are actually context menus that are displayed when a file is dragged with the right mouse button. Although we won’t create any, drag-and-drop handlers are discussed along with context menu handlers in Chapter 4.

Icon handler

Icon handlers allow files of the same type to have different icons. These icons could indicate the state of the data contained within the files or provide other additional feedback. Creating icon handlers is covered in Chapter 5.

Property page extension

The property page dialog appears when you select Properties from a file’s context menu. A property page extension allows you to add property tabs to this dialog. This is a convenient way to allow users to access various elements of the data contained within the files without starting up an application. All of Microsoft Office’s documents have property page extensions defined for them. Developing property sheet handlers is discussed in Chapter 6.

Drop handler

Drop handlers allow your files to become drop targets. This allows files of any type (that you wish) to be dropped on a specified file type. The drop handler can then perform any processing that you might need on the two files—perhaps a file comparison, for example. Creating drop handlers is covered in Chapter 7.

Data handler

Data handlers allow you to modify what happens during a copy, cut, or paste operation for a given file type. Developing custom data handlers is discussed in Chapter 8.

Copy hook handler

Copy hook handlers allow you to permit or prevent a given file from being copied or renamed. Developing copy hook handlers is discussed in Chapter 9.

InfoTip handler

InfoTip handlers provide tool tips for your file. With this tool tip, you can convey information right from the shell about the file in question, such as who wrote it or when it was created. Creating InfoTip handlers is treated in Chapter 10.

Part III

Part III contains only Chapter 11, but it’s a large chapter indeed. This chapter is designed to introduce you to the very prodigious world of namespace extensions. During the course of this chapter, we will build a simple namespace extension that displays a hierarchy of arbitrary objects. The project is a very simple one that’s designed only for the purpose of introducing you to the concepts of namespaces and of developing namespace extensions. However, source code for two real world examples—a registry namespace extension and running object table (ROT) namespace extension—is also provided. By installing the registry namespace extension, for instance, you can view and navigate your system registry just as if it were part of your filesystem.

Part IV

Part IV includes Chapter 12 through Chapter 14. These chapters are concerned with extending the functionality of Internet Explorer, which, as of shell version 4.71 (that is, Internet Explorer 4.0), was basically integrated with the shell. But don’t let that fool you. Even though the focus of these chapters is developing for the Internet, these components can be written for Explorer, too. In these three chapters, we will build the following four projects:

Browser helper objects

Browser helper objects (or BHOs) are components that sit between the Internet and the browser. With them, you have access to every HTML tag on every page that you surf. Also, you can capture any event supported by the browser. This means you can use BHOs to perform a wide variety of Internet-related tasks. Developing BHOs is the focus of the first half of Chapter 12.

Browser extensions

Browser extensions are similar to browser helper objects, but they are only available for Internet Explorer 5.0. Unlike BHOs, browser extensions can have an associated menu item and toolbar button that is available from Internet Explorer. Browser extensions are covered in the second half of Chapter 12.

Band objects

The Search, History, and Favorites windows that are part of Internet Explorer are actually band objects. Remember the ill-fated Channel window in Windows 98? That was a band object, too. If you have an Internet-related application that needs a user interface, a band object is the way to go. Band objects are discussed in Chapter 13.

Docking windows

Docking windows are basically toolbars that you can add to Explorer’s client area. These can be docked on all four borders of Explorer’s client area and can provide a means for components like namespace extensions, browser extensions, and band objects to provide additional user interface capability. Developing docking windows is covered in Chapter 14.

In Part II through Part IV, each chapter follows a similar format, which consists of the following four major sections:

How the shell extension works

This section provides critical background information on the particular shell extension but also can be useful when debugging an application that doesn’t behave quite as expected. It covers such topics as how the shell knows that the shell extension exists in the first place and how the shell and the extension communicate with one another.

The interfaces and their methods

The operation of shell extensions is based on the Windows shell loading the extension and calling methods of its interfaces. This section documents those interfaces and their methods. You can read this section to gain an understanding of what interfaces and which methods are used in a particular kind of shell extension. You can also return to this section when you need a reference source when developing your own shell extensions.

Implementing the extension

In this section, we develop our example shell extension. Here you can see how a shell extension might be implemented, as well as look at some working Visual Basic code.

Registering the extension

This final discussion covers the process of installing and registering the shell extension on a particular system. The central part of this section is typically a .reg file, which registers the extension in the system registry. In most cases, the file need only be slightly modified to work with any shell extension that you might build.

Get VB Shell Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.