Installer Associations

See Also   Tasks

An important step in authoring an installer package is to plan for target machine implementation of document types and COM objects installed with your product. By establishing the document types your product works with, associating them with file extensions, and associating file extensions with valid actions, you make it possible for the target machine to handle your designated document types correctly.

By establishing COM objects and their associated properties and registry entries in your installer project, you make it possible for the Microsoft® Windows® installer to register the COM objects on the target machine. Enabling Windows installer registration of COM objects means your users can roll back COM object installation and registration if the product installation fails. Windows installer registration of COM objects also facilitates advertising COM objects on the target machine.

For more information about the benefits of registering COM objects in a Windows installer compliant manner, search for "Modifying the Registry" in the MSDN™ Library under the topics, Platform SDK, Setup and Systems Management Services, Setup, and Windows Installer Programmer's Reference.

The Associations editor in Microsoft® Visual Studio® Installer provides a simple way to establish the necessary associations. Specifically, you can create and associate the following objects:

Document Types

In Visual Studio Installer, you can add new document types, associate document types with file extensions, and associate file extensions with verbs. (Verbs are Windows Explorer context menu commands.)

Document Types

Consider an example of creating an installer for a word processing product. You might create a document type, Word.Document, your word processor can open, print, and edit. You give the document type a name (in this example, Word.Document) when you create it.

File Extensions

File extensions are associated with document types. Suppose you have established the Word.Document type in an installer for a word processing product. Then, you could create the extension .doc and associate it with the Word.Document type. Establishing this association means files with the extension .doc are treated as files of the Word.Document type.

You could create and associate other extensions with the Word.Document type — for example, .rtf. Setting up .rtf as another extension associated with the Word.Document type would establish that any files with an .rtf extension are also treated as Word.Document files. Providing you had already associated the .doc extension with the Word.Document type, both .rtf and .doc files are designated as Word.Document type.

Verbs

Verbs are associated with file extensions, and designate the actions available for each file extension. When you associate a verb with a file extension, that verb is displayed in your users' Windows Explorer context menu for files with that extension. (In Windows, the user displays the context menu by right-clicking a file name.)

To continue the word processing product example, suppose you associate the verb open with the file extension .doc. This means, when users right-click file names with the .doc extension, they will see Open as a Windows Explorer context menu option.

Important   In order for the context menu options to work, you must ensure your installed application knows how to process each verb you associate with file extensions.

When you create document types and associate them with extensions and verbs, you establish everything the target machine must know to work with the document type:

MIME Types

You can establish new MIME (Internet or e-mail) types installed with your product, give each MIME type a name, and associate MIME types with extensions and COM objects. Setting up MIME types and their associations makes it possible for the target machine to handle your installed MIME types correctly (just as setting up document types with their extension and verb associations makes it possible for the target machine to handle document types correctly).

COM Objects

You can specify the COM objects installed with your product and associate each installed COM object with a type library, document type, and icon. This ensures the COM object is correctly installed and registered on the target machine.

Correctly installing and registering COM objects is necessary to take advantage of Windows installer rollback and advertising features. As explained in The New Microsoft Windows Installer, two powerful features of the Windows installer are the abilities to:

To support rollback of component installation and registration if your product installation fails, as well as component advertisement on the target machine, you must register installed COM objects by establishing the necessary associations. You can choose not to do so by self-registering your installed COM objects, but this sacrifices the enhanced Windows installer rollback and advertising functionality.

With traditional scripted setup programs, self-registration was the accepted method for installing COM objects, and it is still a viable method. However, the Windows installer cannot perform rollback installations and registration of self-registered COM objects, and it cannot advertise those objects. This is because self-registering COM objects do not pass their installation and registration information to the Windows installer, so the installer does not have the information necessary for rollback or advertisement.

To ensure the Windows installer knows enough about your installed COM objects to perform a rollback on or advertise them, you must install those COM objects in a manner compliant with Windows installer requirements. With the Associations editor in Visual Studio Installer, you can install Windows installer-compliant COM objects.

Type Libraries

A COM object installed in compliance with Windows installer requirements must have an associated type library. The type library is a compiled file containing important information about the COM object, including:

Type libraries exist in one of these forms:

With the Associations editor in Visual Studio Installer, you can easily associate type libraries with their corresponding COM objects.