3.3 Registry Settings

only for RuBoard - do not distribute or recompile

3.3 Registry Settings

The registry plays a critical role in defining the shell extensions available for particular filesystem objects. In this section, we'll look at how the registry is used to define the shell extensions for particular file types, as well as how it determines the scope of a particular shell extension.

3.3.1 File Associations

There are two entries in the registry that are associated with files of a specific type: the file association key and the application identifier key. For example, in Figure 3.6, HKEY_CLASSES_ROOT\.rad is a file association key. The file association key merely points to the application identifier key; that is, its default value contains the name of the application identifier key, which in the case of Figure 3.6 is HKEY_CLASSES_ROOT\radfile . The application identifier key contains the shellex subkey ( shellex stands for "shell extension"), which defines the specific handler types and the CLSIDs of the objects designated to handle them. Some handlers, like context menu handlers and property page handlers, require a named value that points to the proper CLSID. This can be any name, but it must be unique at the level in which it resides .

Figure 3.6. Registry settings for shell extensions of a specific file type

Once Explorer has the CLSID for the component that is implementing a particular shell extension, it can find the physical location of the component by going to the HKEY_CLASSES_ROOT\CLSID key and finding the matching CLSID. A subkey of the CLSID key called InProcServer32 contains the physical location of the component. Explorer can then load the component and call methods on the appropriate interfaces. Figure 3.7 shows the mapping from a CLSID to a physical location.

Figure 3.7. How an icon handler is mapped to a physical location

When Explorer loads our component, it gets a pointer to its IUnknown interface. Explorer can then call all of the methods that we have implemented for a given shell extension.

3.3.2 Scope

All file objects can have handlers associated with them. The scope is determined by where the handlers are registered in the registry. All of these locations are direct subkeys of HKEY_CLASSES_ROOT and themselves contain subkeys similar to those found in Figure 3.6. These include:


This key can be used to register context menu handlers, property sheet handlers, and copy hook handlers that apply to all registered file objects. For example, WinZip uses a subkey of this key to define a context menu handler that examines the type of filesystem object and, if it is either a file or a folder, adds an "Add to Zip" context menu item.


This key is used to register shell extensions for all drives . For example, a property sheet handler defined by a subkey of the Drive key displays information on the free and used space available on the designated drive.


All handlers that are registered by HKEY_CLASSES_ROOT\* can also be registered here, with the addition of drag-and-drop handlers. These handlers apply to all folders in the system. For example, a subkey of HKEY_CLASSES_ROOT\Folder defines a Sharing option for a folder's context menu.


Handlers for all system printers are registered here. The type of handlers that are allowed for this key are the same as Folders , but additional extensions are provided to handle adding and removing printers and setting the default printer.


The Directory key has the same configuration as the Folders key, but is only used for filesystem folders. Examples of system folders include History , Favorites , Downloaded Program Files , and Offline Web Pages . These folders can usually be found under your Windows directory.


This subkey is used to create context menu handlers that are not associated with any particular file object, but rather with the empty area of a system folder. This can be demonstrated with the History system folder, which is located under the Windows directory. This folder does not contain files. It contains browsing histories. Right-clicking in this folder supplies a context menu specific to the objects contained in the folder. It is a slightly different context menu than you would find in a folder containing files.


This key contains the same entries as Folder and pertains to all filesystem objects. It is used to define a handler that determines whether a Send To option appears on the object's context menu.

only for RuBoard - do not distribute or recompile