The Type Library

As a single owner's manual is a book, a collection of books is called a library. In OLE, a collection of the type information for any number of elements (objects, interfaces, and so forth) is called a type library. OLE's type information service is really a service for creating and manipulating information that is contained in a type library. The library itself has only a little bit of its own information—it is primarily concerned with storage and retrieval of type information for the elements within it. So for the most part, the type library acts as a librarian, meaning that you, like a client or user of any library, can ask it to locate the type information for some element of interest.

A type library is nothing more than a collection of static data structures for each element within it, and those structures contain additional nested structures to describe their contents. In this sense, the library itself is not an "object," as it doesn't have any inherent functionality. OLE provides the wrapper objects—its type library service with appropriate interfaces—to let you work with these underlying structures without having to know the exact structures themselves. Because interfaces are language-independent constructs, OLE's services here are usable from any client and can be used to describe any object, regardless of implementation. As I mentioned before, type information is a language-independent and structured way to combine the contents of header files, help files, and import libraries.

In this section, we'll first look briefly at the types of elements that can go into a type library and the attributes that can exist for those elements. In the following section, we'll see how to create a type library. For most of us, this will involve writing a script in ODL, the Object Description Language, and running that script through a compiler called MKTYPLIB.EXE. But this is just a convenient tool: OLE actually provides a more fundamental creation service that we'll look at first. After we know how to create a library, which invariably creates a disk file containing the binary data structures, we can see how to register its location and how to load it. Once it's loaded, we can then look into the details about retrieving the information within the library.