What are Type Libraries?

A Type Library is a block of data which describes one or more COM Object Classes.  The internal format of the data is not important, because it is seldom accessed by application programs.  Typically, it is only accessed by COM Browsers such as PBROW.EXE (supplied with PowerBASIC), TypeLib Browser from Jose Roca, or OLEVIEW.EXE from Microsoft.  In the unusual circumstance that you must access this data directly, the Windows API provides numerous functions for just that purpose.

A Type Library is usually supplied by the author of the COM server. It's frequently supplied as a standalone data file with a file name extension of TLB.  The data can also be embedded as a resource in the associated DLL or EXE.  In practice, you would generally use a COM Browser to extract enough information about a COM Object to allow you to use these classes in your program.  Generally speaking, a Type Library usually supplies specific details about every METHOD and PROPERTY (function), and the parameters of each of them.  This would include the names, data types, return values, and more.  The Type Library may also offer information about related equates, User-Defined-Types, and more.

Traditionally, it was common to use Interface Definition Language (IDL) to create the source code for the definitions you wish to describe in a Type Library.  IDL was created specifically for this purpose and resembles C++ syntax.  Once the source code was written, you would use Microsoft's MIDL Compiler to create the final Type Library.  That's a fairly cumbersome process.

With PowerBASIC For Windows, it's a bit simpler than that.  Whenever you create a COM server, your Type Library is created automatically.   It is created with the same primary name as your COM server, and a file extension of TLB.  That is, if you create a COM server named XX.DLL, PowerBASIC will name the Type Library as XX.TLB.  The Type Library offers a description of every published class on the server.  You can then use any COM Browser to display the type information in a format that meets your needs.  The PowerBASIC COM Browser converts it directly to PowerBASIC source code declarations which can then be dropped into your COM client program.

 

See Also

What is an object, anyway?

Where are objects located?

Why should I use objects?

How do you publish an object?