WAssociate icon Associations

< Introduction
Using WAssociate >


Introduction

This page gives some background on how the Windows shell handles file name extensions. If you are familiar with file name extensions and their associations, or just don't like reading a lot of text right now, you can take a short cut, and dive right into Using WAssociate.


Extensions

The part of a file name behind the right most dot is called file name extension. For a file named "My text.txt" the extension is ".txt". Based on properties associated with a file name extension Windows determines how to display a file and what should happen when you manipulate it. These properties specify things like Icon, description and what program to start when you double click it.

WAssociate showing extension .txt

WAssociate showing .txt and associated file type txtfile


File types

An extension can be associated with a file type specifying additional properties. Multiple extensions can be associated with one file type to share properties. In the image above you see extension .txt associated with file type txtfile, specifying an Icon, the Dutch description "Tekstdocument" and Notepad as the program to start when you double click a text file.


Classes

An extension can be associated directly with a class, or indirectly when its file type specifies a class. Classes specify the implementations of OLE and COM objects. The following image shows the .doc extension associated with file type Word.document.8 and Word.Document.8 specifies the class with CLSID {00020906-0000-0000-C000-000000000046} as the class to use when you manipulate a Word document.

WAssociate with Word document

WAssociate with Word document.


HKEY_CLASSES_ROOT

The registry is organized in keys and values like the file system is organized in folders and files. When you use WAssociate, you might encounter names like txtfile, bmpfile, Folder, Unknown, * which might give you a clue of what they stand for.

All extensions, file types and classes are stored in the Windows registry beneath the registry key HKEY_CLASSES_ROOT. The file type for files having extension .txt is stored in the registry key HKEY_CLASSES_ROOT\.txt and its associated file type, mostly txtfile, can be found in the key HKEY_CLASSES_ROOT\txtfile. Classes can be found beneath the key HKEY_CLASSES_ROOT\CLSID key and the applications beneath HKEY_CLASSES_ROOT\Applications. These settings are valid for the whole workstation.


Applications

Next to file type and class you can associate an application with an extension. The setting of an application overrides the settings specified for the file type. File type and class settings are valid for all users of the workstation, the association between extension and application are only valid for the current user. The associations are stored in HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts and the applications themselves are stored in the key HKEY_CLASSES_ROOT\Applications.


Editing associations

When you double click a file with an extension still unknown to Windows, on most systems you get a dialog asking which program to start. If you check 'Always use this program', give a description and click OK, you establish an association between extension, description and selected program.

Windows stores the extension in its registry in the key HKEY_CLASSES_ROOT\.extension, creates a file type and stores it with description, selected program and optional icon in the key HKEY_CLASSES_ROOT\GeneratedFileTypeName. From now on it tries to use this program when handling files with this extension.

If you shift right click a file in Explorer, you see the 'Open as ...' item to start an alternative program. This way, as with an unregistered extension, you can change the program for the open action by checking the checkbox 'Always use this program'.

You can use the option dialogs of Explorer or a registry editor like RegEdit to access associations beneath HKEY_CLASSES_ROOT.

With WAssociate, getting from a file in Explorer to its associated properties can be as far as one click away. If you finished the last example, you know how.


Action

In HKEY_CLASSES_ROOT\txtfile\Shell the Windows shell keeps track of actions that can be applied to text files. File extensions, types, classes and applications can all have actions associated with them. The Windows shell will summarize available actions when the user right-clicks a file, and present them in its context menus, ready to launch.

The following image shows some actions for a dutch HTML file stored beneath HKEY_CLASSES_ROOT\htmlfile\shell and how they appear in the alternate menu of Explorer. The image was grabbed using a previous version of WAssociate explaining the different look of WAssociate.

Image 3 WAssociate with HTML file

Image 3 WAssociate with HTML file showing action edit, with mixed English Dutch description "Edit met &Word" appearing in context menu of Explorer.

Open action

Windows executes a default open action when you double click an Icon. The default open action will appear bold in Explorers context menu. It starts with looking for the open command of an associated application, if present, than the open command of the file type and than the class and finally the extension. If none of them specify an open action, the shell looks at the actions registered with file type *, giving priority to open. If * does not specify an action, the first found action for again the file type, class, extension and finally *, will be used.

File type Unknown

If this search still is without any success, the shell starts searching the file type Unknown which it uses to handle unregistered extensions. It first looks for an open action for Unknown, then the open action of *, followed by the other actions of * and finally it looks at the other actions specified with Unknown. Often Unknown has no open action, and * has no actions at all, resulting in the execution of the well known 'Open as...' dialog from Shell32.dll. You can find this dialog specified as the openas action of file type Unknown.

Order

To change the default ordering of actions, an ordering of actions can be specified in registry key HKEY_CLASSES_ROOT\[extension, file type or class]\Shell, separated by semicolons (;). In image 3 you can see how the action opennew is given priority to open by specifying it in HKEY_CLASSES_ROOT\htmlfile\Shell


Documentation

Some programs do a nice job storing descriptions of used documents and associations in your registry. Some documentation can be found in the Microsoft Programmer References at http://msdn.microsoft.com. After reading Using WAssociate you might have some control over them.


<<< Introduction Using WAssociate >>>