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.
- Interface Definition Language:
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
.
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.