I am a COM beginner and trying to use a managed library in my c++ project through COM.. I could able to create instance for the dual interfaces and call methods... it is working fine...
I would like to know how to construct client interface which can receive events from any dispinterface COM object ?
#include "stdafx.h"
#import "../COMLib/bin/Debug/COMLib.tlb" named_guids
#include <comutil.h>
int _tmain(int argc, _TCHAR* argv[])
{
CoInitialize(NULL);
COMLib::ICalcPtr pCalc;
HRESULT hRes = pCalc.CreateInstance(__uuidof(COMLib::Calc));
if(FAILED(hRes))
printf("ICalcPtr::CreateInstance failed w/err 0x%08lx\n", hRes);
else
{
printf("%d\n", pCalc->Factorial(10));
}
CoUninitialize();
return 0;
}
I know how to create instance for dual interface like above. But I need help to instantiate dispinterface for events. Your help is much appreciated.