Basic COM  «Prev  Next»

midl COM - Exercise

Objective: Compile IMyComInterface.idl.


  1. Create a file called IMyComInterface.idl.
  2. Copy the IDL definition of IMyComInterface below into it.
    import "unknwn.idl";
    [object, uuid(673B0E01-4987-11d2-85C0-08001700C57F)]
    interface IMyComInterface : IUnknown
    HRESULT Fx1(CHAR *buf);
    HRESULT Fx2();
    [object, uuid(24A4A631-4B59-11d2-85C2-08001700C57F)]
    interface IYourComInterface : IUnknown
    HRESULT Zx1(LONG ix);
  3. Run guidgen and paste your own uuid's into the uuid(...) in each interface attribute section.
  4. Open a Command window.
  5. Run vcvars32.bat from the Visual C++ bin directory.
  6. Compile IMyComInterface.idl with MIDL as follows: midl IMyComInterface.idl.
  7. Examine the contents of IMyComInterface.h and IMyComInterface_i.c to see how MIDL generates interface classes and IDs.

Exercise scoring

This exercise is worth 5 points and is scored automatically. Follow the instructions listed above. When you are finished, click the Submit button for the exercise.