NotLogical
asked on
How to create COM sink using MFC?
Hello,
I am having difficulties implementing a sink for a COM object dispatch interface. This is an MFC console application, so using wizards to add CCmdTarget automation is not an option.
I am not having any issues with using other interfaces (calling from my app into the COM object). It is the sink where I am running into a snag (from _Notify).
Here is a snippet of the TLH file, for which I need to implement the sink:
struct __declspec(uuid("2e21b3ec- f00f-f00f- 8973-46d10 9c82f47")) _TheLib;
struct __declspec(uuid("C3520671- f00f-f00f- 9b96-00600 83968AE")) _Notify;
TLI file for the interface of interest:
inline HRESULT _Notify::OnNotifyMsg ( )
{
HRESULT _result = 0;
_com_dispatch_method(this, 0x2, DISPATCH_METHOD, VT_ERROR, (void*)&_result, NULL);
return _result;
}
Here is the IDL:
library TheLib
{
// TLib : // TLib : OLE Automation : {00020430-0000-0000-C000-0 0000000004 6}
importlib("stdole2.tlb");
// Forward declare all types defined in this typelib
dispinterface _Notify;
[
uuid(C3520671-F00F-F00F-9B 96-0060083 968AE),
helpstring("_Notifyinterfa ce")
]
dispinterface _Notify{
properties:
methods:
[id(0x00000002)]
HRESULT OnNotifyMsg();
};
};
I've generated the IDispatch wrapper class using the Add Class from Typelib Wizard. I've then attempted to inherit and extend the method which I am interested in - but the sink never receives any events.
I would greatly appreciate help with this. I've tried many different ways of doing this, and have looked through other posts about this subject on Experts Exchange - without too much help.
Thanks everyone!
NotLogical
I am having difficulties implementing a sink for a COM object dispatch interface. This is an MFC console application, so using wizards to add CCmdTarget automation is not an option.
I am not having any issues with using other interfaces (calling from my app into the COM object). It is the sink where I am running into a snag (from _Notify).
Here is a snippet of the TLH file, for which I need to implement the sink:
struct __declspec(uuid("2e21b3ec-
struct __declspec(uuid("C3520671-
TLI file for the interface of interest:
inline HRESULT _Notify::OnNotifyMsg ( )
{
HRESULT _result = 0;
_com_dispatch_method(this,
return _result;
}
Here is the IDL:
library TheLib
{
// TLib : // TLib : OLE Automation : {00020430-0000-0000-C000-0
importlib("stdole2.tlb");
// Forward declare all types defined in this typelib
dispinterface _Notify;
[
uuid(C3520671-F00F-F00F-9B
helpstring("_Notifyinterfa
]
dispinterface _Notify{
properties:
methods:
[id(0x00000002)]
HRESULT OnNotifyMsg();
};
};
I've generated the IDispatch wrapper class using the Add Class from Typelib Wizard. I've then attempted to inherit and extend the method which I am interested in - but the sink never receives any events.
I would greatly appreciate help with this. I've tried many different ways of doing this, and have looked through other posts about this subject on Experts Exchange - without too much help.
Thanks everyone!
NotLogical
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
The article you offered is quite interesting, although the XYDispDriver class which is discussed only connects one COM object's dispatcher to another one. This is done in a console application, but it unfortunately does not create a sink within said console application.
Thanks,
NotLogical