Typelib and Registrations

Registration of type library information is mandatory for classes that are to be used by automation clients. You should register your type library if you want the object that you've created, whether it's local or remote, to be usable by VBScript and JAVAScript in Internet Explorer, and Visual Basic as well as Java.

Recall from Chapter 2 that type libraries are maintained in .TLB files generated by the MIDL compiler from the project's .IDL file. But, ATL also combines the type library information with the generated executable (either .EXE or .DLL). When we do a regsvr32 <name>.DLL or a <name>.EXE /RegServer, the type library registration is also performed automatically.

Let's look into the registry and see where these type libraries are actually located. In general, a type library can be located under:

\HKEY_CLASSES_ROOT\TYPELIB\{Type library’s UUID}

Taking our ATLFinder local server as an example, we find the following registry values:

Matching this with the Atlfinder.idl that we've created in Chapter 7, we can see the correspondence.

[
   uuid(721B4F00-4D27-11D0-8564-004005263AF7),
   version(1.0),
   helpstring("ATLFinder 1.0 Type Library")
]
library ATLFINDERLib
{
... skipped interface and coclass definitions   
};

The GUID of the type library is used as the main key under \HKEY_CLASSES_ROOT\TYPELIB. Then a subkey containing <MajorVersion.MinorVersion> has a default value that is the name or 'helpstring' attribute in the IDL file. Under this subkey, there can be a FLAGS subkey. This subkey can contain a unary ORed combination of the following values:

FLAGS value Description
1 Restricted—no user tools should display or use this type library.
2 Control—the type library contains descriptions of controls. Tools which examine nonvisual objects should skip this library.
4 Hidden—this library should not be displayed to the users, but can be used by controls.

The actual location of the type library information, in this case the Atlfinder.exe file with the TLB information merged in as a custom resource, can be found under a subkey with 0\win32. The 0 subkey is there mainly for historical reasons. Older OLE implementations had no means of deleting a type library entry programmatically, so the numeric index is used to keep track of older versions of the type library.

The HELPDIR subkey specifies the path to the .HLP file associated with this type library. If a type library is published for commercial or production purposes, a context index can be associated with a help file for each item in the type library to give more information to the end user as they browse the type library.

© 1997 by Wrox Press. All rights reserved.