Interface Definitions and Type Libraries

In distributed computing, an interface is a collection of definitions and functions that enables two or more elements to interoperate. In an RPC application, this interface specifies how the client and server applications will identify themselves to each other, the remote procedures that the client application can call, the data types for the parameters and return values of those procedures, and how the data is transmitted between client and server. In MIDL, an RPC application can have one or many interfaces, each specifying a unique network contract between client and server.

COM uses this RPC model to allow component objects to communicate with each other. Thus, a COM (or DCOM) interface defines the identity and external characteristics of a COM object — the means by which clients can gain access to the object's methods and data. With DCOM, this access is possible regardless of whether the objects exist in the same process, different processes on the same machine, or on different machines. As with RPC client/server interfaces, a COM object can expose its functionality in a number of different ways, through multiple interfaces.

A type library (.TLB) is a binary file that stores information about a COM object's properties and methods in a form that is accessible to other applications at run time. Using a type library, an application or browser can determine what interfaces an object supports, and invoke an object's interface methods, even if the object and client applications were written in different languages. The COM run-time environment can also use a type library to provide automatic cross-apartment/process/machine marshaling for interfaces described in type libraries.

You define the characteristics of an interface in an interface definition (IDL) file and an optional application configuration (ACF) file. The IDL file specifies the characteristics of your application's interfaces "on the wire," that is, how data is to be transmitted between client and server, or between COM objects. The ACF file specifies interface characteristics, such as binding handles, that pertain only to the local operating environment. You can also use the ACF file to specify how to marshal and transmit a complex data structure in a machine-independent form.

The IDL and ACF files are scripts written in Microsoft® Interface Definition Language (MIDL), which is Microsoft's implementation and extension of the OSF-DCE interface definition language. (The Microsoft extensions to the language allow you to create COM interfaces and type libraries.) The compiler, Midl.exe, uses these scripts to generate C-language stubs and header files as well as type library files.

Depending on the contents of your IDL file, the MIDL compiler will generate any of the following: