using COM Events in c++

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have develloped a COM component in C#. For testing it, I wrote a
testapplication in C++ ( unmanaged ), the functions are no problem but the
events are. I do not know how I can connect to the connection point that the
wrapper provides.

I don't have verry much experiance with COM, and the examples of microsoft
are not helping me understanding how to do it.

This is how I load the COM, Can You help me, how I can Implement the
eventfuntions in my C++ program that the com will fire?


HRESULT hr;
hr = CoInitialize(NULL);

try
{
hr = spPlc.CreateInstance("PlcHandlerLib.Library");
}
catch(_com_error)
{
this->MessageBox("Can not open the DLL file, first register it and restart
the application!!");
}



The next lines are from the .tli file that visualStudio created for me and
represent the eventfuntions I want to implement.


//
// dispinterface IPlcHandlerLibEvents wrapper method implementations
//

inline HRESULT IPlcHandlerLibEvents::LowLogOnFinished ( ) {
return _com_dispatch_method(this, 0xb478, DISPATCH_METHOD, VT_EMPTY,
NULL, NULL);
}

inline HRESULT IPlcHandlerLibEvents::LowLogOutFinished ( ) {
return _com_dispatch_method(this, 0xb479, DISPATCH_METHOD, VT_EMPTY,
NULL, NULL);
}


Thanks.
 
Back
Top