StdGlobalInterfaceTable provides a way for COM objects to be used from multiple threads in an application, when the threading model of the object doesn’t allow the cross-thread calls to be made from the pointer returned when the object was created.

The sequence of events is as follows:

  1. Create the com object on some thread.
  2. Get a StdGlobalInterfaceTable object.
  3. Register the interface with the Global Interface Table.
  4. Using the cookie returned when the object was registered, get a safe pointer from any thread.
  5. Use that pointer to make calls on the interface.


Create the COM object:

IDspPtr m_pDspX;

HRESULT hr = m_pDspX.CreateInstance(__uuidof(Dsp));

Now create a StdGlobalInterfaceTable object:

CComPtr<IGlobalInterfaceTable> pGIT;

hr = CoCreateInstance(CLSID_StdGlobalInterfaceTable,
(void **)&pGIT);

Now register our object with the GIT:

DWORD m_dsp_cookie;
hr = pGIT->RegisterInterfaceInGlobal(m_pDspX, __uuidof(IDsp), &m_dsp_cookie);
// m_dsp_cookie now gives us a way to access the dsp from different threads

Use the GIT to get a pointer to the object (in a function that can be called from any thread)

bool CPecoDsp::ReadProbe(int Mask)
IDspPtr pDsp;
HRESULT hr = pGIT->GetInterfaceFromGlobal( m_dsp_cookie, __uuidof(IDsp), (void**)&pDsp );
pDsp = NULL;
return false;
return true;

Leave a Reply

Your email address will not be published. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>