Quantcast
Channel: Plantronics Developer Connection: Message List
Viewing all articles
Browse latest Browse all 377

Re: PlantronicsURE error message box - "Collection was modified; enumeration operation may not execute."

$
0
0

We use COM Integration from a Native C++ application.

 

For example:

 

// SPOKES Interface definitions

CComPtr<ISessionCOMManager> sessMgr;

CComPtr<IComSession> session;

CComPtr<IHostCommand> hostCommand;

CComPtr<IDeviceListener> deviceListener;

CComPtr<IDeviceEvents> deviceEvents;

CComPtr<IDevice> activeDevice;

CComPtr<ICallCommand> callcommand;

CComPtr<ICallEvents> callEvents;

 

 

//Encapsulates event sink defined in SpokesEvents.h

CComObject<SessionManagerEventSync> *sessionMgrEventsSink = NULL;

CComObject<SessionEventSync> *sessionEventSink = NULL;

CComObject<DeviceEventSink> *deviceEventSink = NULL;

CComObject<DeviceListenerEventSink> *deviceListenerSink = NULL;

 

 

...

 

 

  ::CoInitialize(NULL);

 

 

  HRESULT hr = S_OK;

  if (SUCCEEDED(hr = ::CoCreateInstance(CLSID_SessionComManager, NULL,CLSCTX_LOCAL_SERVER, IID_ISessionCOMManager, (LPVOID*)&sessMgr )))

  {

    // hook to session manager events

    CComObject<SessionManagerEventSync>::CreateInstance(&sessionMgrEventsSink);

    AtlAdvise(sessMgr, sessionMgrEventsSink, __uuidof(ISessionCOMManagerEvents), &_pSinkCookie);

    // set function pointers to attach/detach to device when we recieve Device events

    sessionMgrEventsSink->DeviceStateHandlers( AttachDevice, DetachDevice );

 

 

    // register new plugin with Spokes

    if (SUCCEEDED(hr = sessMgr->Register(_bstr_t("COM Plugin"), &session )))

    {

      // hook to Session call events

      session->get_CallEvents(&callEvents);

      if( callEvents != NULL )

      {

  CComObject<SessionEventSync>::CreateInstance(&sessionEventSink);

  AtlAdvise(callEvents , sessionEventSink, IID_ICOMCallEvents , &_pSinkSessionCookie);

      }

    }

    else

    {

      TraceName(ME, TRE_API, -1, "InternalStartup1 - Error - 0x%08x", hr);

    }

  }


Viewing all articles
Browse latest Browse all 377

Trending Articles