Untitled

# Registering an ActiveX Object as the Player for a Media Type

This document describes how to register an ActiveX object as the "viewer" or "player" for a particular media type (MIME). This registration is essential in order for Microsoft Internet Explorer to launch the correct player when interpreting the standard HTML <A HREF> tag or the Netscape-introduced <EMBED> tag. Note that <A HREF> and <EMBED> can instantiate ActiveX objects only when given a data file. Without the registration described below it is impossible for ActiveX containers to guess what application to use to display or play an unknown media file. The registration process associates an ActiveX object with a given MIME type or filename extension so that Microsoft Internet Explorer or any other ActiveX container can launch the correct "player" for files of that type. Microsoft Internet Explorer first tries to find a match for the correct media type, and if that is not possible, the filename extension is used. When finding a viewer for <HREF> to a new file type, Internet Explorer first tries to find an ActiveX Document Object, and if none is found, it will also try to find an OLE Control (matching the OC'94 specification) that is marked as "full-page aware" (see below).

## What information needs to be registered

An ActiveX Object has four pieces of identifying information:

1. The CLSID (Class ID) of the object. This is a Globally Unique ID (GUID). In examples below we will use this CLSID: {01234567-89AB-CDEF-0123-456789ABCDEF}
2. The "ProgId" of the object. This is a textual "program ID". In examples below we will use the progid "FooCorp.BarControl"
3. The MIME Type for media types the object understands. Note: not all ActiveX Objects are viewers or players for media types, so not every object needs to be associated with a MIME type. For examples below, we will use the MIME Type "application/foobar".
4. The File Extension for media types the object understands. Note: not all ActiveX Objects are viewers or players for media types, so not every object needs to be associated with a file extension. For examples below, we will use the extension ".foo".

## Step 1: Registering the CLSID for the ActiveX object

All ActiveX/COM objects must be entered in the registry so COM knows how to instantiate the object servers from the appropriate executable file. For full details on this registration process, see the COM Specification or OLE Reference (Win32 SDK). A simple in-proc server would enter information such as the following in the registry:

        HKEY_CLASSES_ROOT\CLSID\
            {01234567-89AB-CDEF-0123-456789ABCDEF}\
                InProcServer32            DLL File location
                ProgId                    FooCorp.BarControl
                ......

To see an example, run regedit.exe and look under HKEY_CLASSES_ROOT\CLSID.

It is possible for an OLE Control (matching the OC'94 specification) to act as an embedded viewer for <EMBED> tags. For this to happen correctly, it is necessary to include the "Control" keyword in the registry settings for the control:

        HKEY_CLASSES_ROOT\CLSID\
            {01234567-89AB-CDEF-0123-456789ABCDEF}\
                Control                   (value not set)

It is also possible to register an OC'94 OLE Control as a "full-frame" viewer so it is used as the viewer/player when following <A HREF> hyperlinks to a particular media type. In order to mark an OLE Control as capable of "full-frame" display, you must mark it with the "Control" keyword as described above, and also add the following registry information to enable full-frame viewing for particular data types:

        HKEY_CLASSES_ROOT\CLSID\
            {01234567-89AB-CDEF-0123-456789ABCDEF}\
                EnableFullPage\
                   .foo

Note: a requirement of this "EnableFullPane" registration process is to register the control as the viewer for the ".foo" file extension as described below. The requirement for the control to match the OC'94 specification is there because otherwise the object marked "Control" will show up in other OC'94 containers but will not work correctly. Future versions of Internet Explorer should allow non-OC'94 ActiveX Controls to work correctly with <EMBED> and <A HREF>.

Back to top.

## Step 2: Associating the object's CLSID with a ProgId

In order to associate a given ActiveX object with data types, it is first necessary to associate the object CLSID with a ProgId (Program ID). This is explained fully in the COM Specification or OLE Reference pages (Win32 SDK), and is illustrated in the simple example below for defining the new ProgId "FooCorp.BarControl":

        HKEY_CLASSES_ROOT\
            FooCorp.BarControl\
                CLSID                     {01234567-89AB-CDEF-0123-456789ABCDEF}

Also under the ProgId key it is possible to register shell commands to be used to edit or open files for this ProgId, for example:

        HKEY_CLASSES_ROOT\FooCorp.BarControl\
            Shell\Open\
                Command                   c:\Program Files\foobar.exe %1

Back to top.

## Step 3: Associating the object with a MIME type

It is possible to associate an ActiveX object as a viewer for various media types. The following keys must be entered in the registry to associate a given ActiveX object with a given media type application/foobar:

        HKEY_CLASSES_ROOT\
            MIME\Database\Content Type\
                application/foobar\
                    Extension             .foo
                    CLSID                 {01234567-89AB-CDEF-0123-456789ABCDEF}

Note: neither the "Extension" nor the "CLSID" keys are necessary. One associates the MIME type with a file extension, the other associates it with the CLSID of an ActiveX object.

Back to top.

## Step 4: Associating the file extension with a ProgId and optionally with a MIME type

If an ActiveX container such as Microsoft Internet Explorer does not have a (server-provided) MIME type to choose a viewer for a new data type, the data filename extension is used to find the appropriate ActiveX object to understand the new media format. If the filename extension is associated with a MIME type, the MIME-CLSID mapping is used to pick the object. Otherwise, the extension-ProgId mapping is used. The example below shows how to associate a 3-letter file extension with a MIME type and a ProgId, although the MIME association is optional

        HKEY_CLASSES_ROOT\
            .foo\
                (Default)                 FooCorp.BarControl
                Content Type              application/foobar

Back to top.