MIDL: Compiling IDL files
Inside the MIDL-generated files
As discussed above, the MIDL-generated interface definitions use a set of macros defined in a standard include file objbase.h.
Following are the definitions of both interfaces after C++ preprocessing:
IMyComInterface : public IUnknown
virtual HRESULT __stdcall Fx1
(unsigned char *buf) = 0;
virtual HRESULT __stdcall Fx2( void) = 0;
IYourComInterface : public IUnknown
virtual HRESULT __stdcall Zx1
(LONG ix) = 0;
Notice how these definitions are similar to the manually coded version we did in the previous lesson.
Also remember that in C++, with some exceptions, a
struct and a class can be used interchangeably.
_declspec(uuid(…)) directive is used by Visual C++ to associate the IID with a type of structure.
One difference between this version and the one we did earlier is that these interface member functions are defined as pure virtual.
This means we can not directly instantiate a class/structure of this type. Instead, we derive a class from
Don't worry about this for now our objective in this chapter is to study IDL, not to build a COM interface.