hi all,
i am having a sdk with fires an event.
i am trying to catch that event in other C++ console application,
i have derived my CEventSink class from IDispEventImpl
EventSink.h:
#pragma once
#include <atlbase.h>
#include <atlcom.h>
static _ATL_FUNC_INFO OnEvent = {CC_STDCALL, VT_EMPTY, 5, {VT_UI4, VT_BSTR, VT_BSTR, VT_I2, VT_BSTR}};
class ATL_NO_VTABLE CEventSink : public IDispEventImpl<1, CEventSink, &__uuidof(_ISourceEvents)>
{
public:
BEGIN_SINK_MAP(CEventSink)
SINK_ENTRY_INFO(1, __uuidof(_ISourceEvents), 1, OnEventES , &OnEvent )
END_SINK_MAP()
CEventSink(void);
~CEventSink(void);
HRESULT STDMETHODCALLTYPE OnEventES (DWORD dwSession, BSTR bszFilePath, BSTR bszName, SHORT Action, BSTR bszMessage);
};
OnEvent method from the sdk is:
[id(0x00000001), helpstring("method OnEvent ")]
HRESULT OnEvent (
[in] long dwSession,
[in] BSTR bszFilePath,
[in] BSTR bszName,
[in] short Result,
[in] BSTR bszMessage);
TestApp.cpp:
#include "stdafx.h"
#include "eventsink.h"
int _tmain(int argc, _TCHAR* argv[])
{
CoInitialize(NULL);
ISource *spEventFiringObject = NULL;
CEventSink* pEventSink = NULL;
HRESULT hr = CoCreateInstance(CLSID_Source, NULL, CLSCTX_ALL, IID_ISource, reinterpret_cast<void **>(&spEventFiringObject));
if(SUCCEEDED(hr))
{
pEventSink = new CEventSink();
hr = pEventSink->DispEventAdvise(spEventFiringObject, &__uuidof(_ISourceEvents));
}
CoUninitialize();
return 0;
}
but DispEventAdvise returns something like
hr = 0xc0000005 The instruction at "0x
what is wrong here?
Thanx in advance.