Accessing interfaces that are not associated with coclasses
I am trying to develop a vc++ client that can handle events through a
COM interface.
I have created a new class CInstrNotifySink and Inherit the ATL class
that implements the IDispatch methods using:
public IDispEventImpl<1, CInstrNotifySink, &Ecco::IID_IRTDUpdateEvent,
&Ecco::LIBID_Ecco,1,0>
I also define the ATL connection point event functions and callback
fns in the same way as in a previous client which I had working fine
for connecting to a different application. However, there are some
differences in the new application which boils down to how I access
the event interface before I use DispEventAdvise.
Previously it was straightforward:
AppOld::IRTDUpdateEventPtr m_pInstrNotifyObj;
HRESULT hr = S_OK;
CComQIPtr<IDispatch, &__uuidof(IDispatch)> ptr;
hr = ptr.CoCreateInstance (L"Ecco.Prices"); //create instance of
coclass
ptr->QueryInterface(AppOld::IID_IRTDUpdateEvent,
(void**)&m_pInstrNotifyObj);
if (hr==S_OK)
{
hr=DispEventAdvise(m_pInstrNotifyObj);
}
I could do this because here because AppOld::IRTDUpdateEvent is part
of the coclass which is created via hr = ptr.CoCreateInstance
(L"Ecco.Prices");
However, in the new application AppOld::IRTDUpdateEvent is not part of
any other coclass so I'm not sure how to do the equivalent. If I do
the above then the m_pInstrNotifyObj pointer is NULL.
To summarise:
Given
AppOld::IRTDUpdateEventPtr m_pInstrNotifyObj;
I want to access the pointer m_pInstrNotifyObj but the interface,
AppOld::IRTDUpdateEvent, is not part of another coclass to simply
CoCreateinstance of the parent class and use query interface for the
pointer (as shown above).
Any help is much appreciated as I am pretty new to COM