I have to raise an event from my library and, one of the parameter is
an IDispatch derived interface:
HRESULT Fire_OnStreamStateChanged( IWaveStream* Sender, short
new_state )
{
HRESULT hr = S_OK;
T * pThis = static_cast<T *>(this);
int cConnections = m_vec.GetSize();
for (int iConnection = 0; iConnection < cConnections; iConnection++)
{
pThis->Lock();
CComPtr<IUnknown> punkConnection = m_vec.GetAt(iConnection);
pThis->Unlock();
CComQIPtr< IDispatch, &IID_IDispatch > pDispatch
( punkConnection );
if (pDispatch != NULL)
{
CComVariant avarParams[2];
....?????
....?????
VariantInit(&avarParams[0]);
avarParams[0].vt = ...???;
avarParams[1] = new_state;
DISPPARAMS params = { avarParams, NULL, 2, 0 };
hr = pDispatch->Invoke(1, IID_NULL, LOCALE_USER_DEFAULT,
DISPATCH_METHOD, ¶ms, NULL, NULL, NULL);
}
}
return hr;
}
How I have to pack the WaveStream* Sender object?
Thanks for the suggestions!
Daniele.
avarParams[1] = Sender;
Or, if you want to pack it manually,
avarParams[1].vt = VT_DISPATCH;
(avarParams[1].pdispVal = Sender)->AddRef();
Remember that parameters should be packed into DISPPARAMS in reverse order: the last (rightmost) parameter goes into avarParams[0], next to last into avarParams[1] and so on.
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not necessarily a good idea. It is hard to be sure where they are going to land, and it could be dangerous sitting under them as they fly overhead. -- RFC 1925
Thanks a lot Igor!!
Daniele.