I have an ATL project which exposes a COM object. I would like my COM object to call a function specified by the consumer from time to time, or via some other means of notifying the consumer from time to time.
I have tried adding a method in CerberusNative.idl
in order to take void function pointers which I would like to call from the COM instance side of things so that the consumer would just need to tell the COM object upon initialization what its callbacks are:
interface ICerberusSession : IDispatch {
[id(5)] HRESULT SetCallbacks([in] void(*userExit)(int, char *), [in] void(*userAttemptingReconnection)(), [in] void(*userReconnected)());
};
However, there are some problems with my void function pointers:
Severity Code Description Project File Line Suppression State Error MIDL2269 procedures in an object interface must return an HRESULT : [( Parameter 'userExit' ) ] Error MIDL2131 parameter must not be a function : [ Parameter 'userExit' of Procedure 'SetCallbacks' ( Interface 'ICerberusSession' ) ]
In what ways can I get a client application to subscribe to callback functions in my COM object?