Marcus Ilgner
Marcus Ilgner

Reputation: 7221

ATL/COM: MIDL compiler doesn't output UUID for dispinterface

While implementing a connection point for events fired from my class, I declared a dispinterface in my IDL like so

[
  uuid(123-MY-GENERATED-GUID)
]
dispinterface _IMyChangeEvents {
properties:
methods:
  [id(1)] void ItemChanged([in] BSTR changeInformation);
};

According to several sources, including the book "ATL Internals", this should produce a DIID__IMyChangeEvents which I can then use to derive my class from ATL::IConnectionPointImpl<ImplClass, IID>. But neither is it there nor can I use __uuidof(_IMyChangeEvents) in the CONNECTION_POINT_ENTRY macro as described in the documentation because it complains "No GUID has been associated with this object".

What's the correct way to implement this?

Upvotes: 0

Views: 1148

Answers (1)

Igor Tandetnik
Igor Tandetnik

Reputation: 52471

Is this code snippet inside or outside the library{} block? Everything outside library{} goes into the generated .h file. Everything defined or referenced inside library{} goes into the generated .tlb file.

A typical .IDL file would look something like this:

interface IMyMainInterface {...};
dispinterface MyEvents {...};

library {
  coclass MyCoClass {
    [default] IMyMainInterface;
    [default, source] MyEvents;
  }
}

This way, you would have everything both in .h and in .tlb, for your clients' convenience.

Upvotes: 2

Related Questions