Здравствуйте, Kitty, Вы писали:
HRESULT _result=S_OK;
IConnectionPointContainer* _connection = NULL;
IConnectionPoint* _point = NULL;
DWORD _cookie;
bool _connected=false;
_result = OBJECT_WITH_EVENTS->QueryInterface(IID_IConnectionPointContainer, (void**)&_connection);
if(SUCCEEDED(_result))
{
//DIID_IEvents - event interface;
_result = _connection->FindConnectionPoint(DIID_IEvents, &_point);
if (SUCCEEDED(_result))
{
_result = _point->Advise(POINTER_TO_IUNKNOWN_INTERFACE_OF_EVENT_HANDLER_OBJECT, &_cookie);
if(SUCCEEDED(_result))
{
//Connected...
_connected=true;
};
_point->Release();
}
_point->Release();
}
//...
if(_connected)
_point->Unadvise();
AND
class YOUR_EVENT_HANDLER : public IDispEventImpl / IDispEventSimpleImpl<...>
{
//...
BEGIN_SINK_MAP
SINK_ENTRY/SINK_ENTRY_EX/SINK_ENTRY_INFO
END_SINK_MAP
};