RAD Studio |  |

Working with Type Libraries: Overview
See Also
Collapse All

Type libraries are files that include information about data types, interfaces, member functions, and object classes exposed by a COM object. They provide a way to identify the types of objects and interfaces that are available on a server. For a detailed overview on why and when to use type libraries, see Type libraries.

A type library can contain any and all of the following:

- Information about custom data types such as aliases, enumerations, structures, and unions.
- Descriptions of one or more COM elements, such as an interface, dispinterface, or CoClass. Each of these descriptions is commonly referred to as type information.
- Descriptions of constants and methods defined in external units.
- References to type descriptions from other type libraries.

By including a type library with your COM application or ActiveX library, you make information about the objects in your application available to other applications and programming tools through COM's type library tools and interfaces.

With traditional development tools, you create type libraries by writing scripts in the Interface Definition Language (IDL) or the Object Description Language (ODL), then run that script through a compiler. The Type Library editor automates some of this process, easing the burden of creating and modifying your own type libraries.

In addition, the Type Library Editor now uses an intermediate text file known as a RIDL file. The Code page of the Type Library Editor displays the RIDL code, and you use the Design page to view and change the type library fields (coClass, Methods, Properties, and so forth). When you save or build your project, the RIDL file is converted to a standard binary .tlb file. Both the RIDL file and the .tlb file are saved in your project.

When you create a COM server of any type (Automation object, remote data module, and so on) using Delphi wizards, the wizard automatically generates a type library for you (although in the case of the COM object wizard, this is optional). Most of the work you do in customizing the generated object starts with the type library, because that is where you define the properties and methods it exposes to clients: you change the interface of the CoClass generated by the wizard, using the Type Library Editor. The Type Library editor automatically updates the implementation unit for your object, so that all you need do is fill in the bodies of the generated methods.

See Also

Creating Simple COM Servers: Overview

Overview of COM Technologies

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!