How to create anonymous IDispatch functions using ATL?

Is there an easy way to create a class that is derived from IDispatch and which can be passed to an API like this (this is C ++):

pDOM2->attachEvent(CComBSTR("event"), new DispatchFunction);

I know how to create a C ++ object that handles a call with an oversight of the value 0, but it is always very difficult to implement all IDispatch manually. I was wondering if ATL has a standard way to do this, as it is fairly common.

+3
source share
1 answer

By default, ATL creates "auto-duplicate" COM classes. They support both early binding and IDispatch. You will see IDispatchImpl <> in your inheritance list. You declare an oversight in the IDL. No extra work required.

+2

Source: https://habr.com/ru/post/1790290/


All Articles