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. 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

Import Definitions from Idl
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 ({}).