Basic COM  «Prev  Next»
Lesson 7 Interface definition language - IDL
Objective Describe a COM interface using IDL.

Interface Definition Language - IDL

In previous lessons, we examined the binary requirements of a COM method and interface; how all COM interfaces implement IUnknown functions:
QueryInterface, AddRef, and Release; and how to use C++ to define a COM interface. This lesson will introduce IDL(the interface definition language) and how to use IDL to define a COM interface.


Separating interface specification from implementation is a standard development practice. This allows designers and developers to study the interface design and interactions before jumping into implementation. Several industry-standard tools and techniques exist to assist with interface specification. IDL can be used to specify COM interfaces and generate header files containing C++ class definitions that implement COM interfaces. The following Slideshow steps through an IDL file called IMyComInterface.idl. It contains the definition of interface IMyComInterface, the same interface we discussed in the previous lesson, and IYourComInterface.

1) Running Programs 1 2) Running Programs 2 3) Running Programs 3 4) Running Programs 4 5) Running Programs 5 5) Running Programs 6
Program 1 Program 2 Program 3 Program 4 Program 5 Program 6
  1. We import definitions from the IDL file
  2. Every interface definition starts with an attributed section delimited by [,] brackets
  3. The Interface, IMyComInterface, is named. Also, IMyComInterface inherits from IUnknown.
  4. The functions Fx1 and Fx2 are placed in IMyComInterface.
  5. The `{`, `}` bracket pairs delimit the interface block
  6. The remainder defines interface IYourComInterface containing method Zx1

Purpose of Interface definition language - IDL

The Microsoft Interface Definition Language (MIDL) defines interfaces between client and server programs. Microsoft includes the MIDL compiler with the Platform Software Development Kit (SDK) to enable developers to create the interface definition language (IDL) files and application configuration files (ACF) required for remote procedure call (RPC) interfaces and COM/DCOM interfaces. MIDL also supports the generation of type libraries for OLE Automation.

Where applicable

MIDL can be used in all client/server applications based on Windows operating systems. It can also be used to create client and server programs for heterogeneous network environments that include such operating systems as Unix and Apple. Microsoft supports the Open Group (formerly known as the Open Software Foundation) DCE standard for RPC interoperability.

Developer audience

When using MIDL with RPC, familiarity with C/C++ programming and the RPC paradigm is required. When using MIDL with COM, familiarity with C++ programming and the RPC paradigm as it applies to COM is required, or alternatively, familiarity with OLE Automation model scripting and type libraries is required.

Run-time requirements

The appropriate run-time libraries for using MIDL are included with Windows. The MIDL compiler and the components of the RPC development environment are installed when you install the Windows SDK. For more information, see Using the MIDL Compiler and Installing the RPC Programming Environment.

The guidgen tool can generate this format. To use this tool, select Registry Format, copy into the clipboard by clicking the Copy button, paste into the UUID attributes, and remove the curly brackets ({}).