I have one com server with some interfaces exposing some API's
COM class looks like below
class ATL_NO_VTABLE CTask :
public CComObjectRootEx<CComSingleThreadModel>,
public CComCoClass<CTask, &CLSID_Task>,
public ITask
{
public:
STDMETHOD (Task)();
STDMETHOD (ABC)();
...
}
Now this com server also contains one more class XYZ
ABC API needs to call XYZ functionality
STDMETHODIMP ABC()
{
XYZ xyz;
xyz.dosomething();
}
dosomething function need to call com server Task function, like below
class XYZ
{
public:
void dosomething()
{
// need to call Task function
}
};
How can this be done? Do I need to CoCreateInstance ITask in dosomething?
I tried creating CTask taskl; in dosomething but it ga开发者_C百科ve some errors.
Class CTask
is non-creatable since it doesn't implement IUnknown
methods. You need to use one of ATL
classes intended for serving as COM objects, for example CComObject
:
CComPtr<ITask> newTask = new CComObject<CTask>();
精彩评论