Figure 4   CoCreateFreeThreadedMarshaler


 struct Dummy : public IUnknown {
     IUnknown *m_pUnkFTM;
     Dummy(void) 
         {CoCreateFreeThreadedMarshaler(this,&m_pUnkFTM);}
     ~Dummy(void) { m_pUnkFTM->Release(); }
         STDMETHODIMP QueryInterface(REFIID r,void **p) {
         if (r == IID_IUnknown)
             *p = static_cast<IUnknown*>(this);
         else
             return m_pUnkFTM->QueryInterface(r, p);
         return S_OK;
     }
     STDMETHODIMP_(ULONG) AddRef() { return 4; }
     STDMETHODIMP_(ULONG) Release() { return 16; }
     static void InitFTMCLSID() {
     extern CLSID CLSID_FreeThreadedMarshaler;
         IMarshal *pMsh = 0;
         Dummy d;
         HRESULT hr = d.QueryInterface(IID_IMarshal, 
                                       (void**)&pMsh);
         if (SUCCEEDED(hr)) {
             hr = pMsh->GetUnmarshalClass(IID_IUnknown, &d,
                                          MSHCTX_INPROC, 0, 
                                          MSHLFLAGS_NORMAL, 
                                          &CLSID_FreeThreadedMarshaler);
             pMsh->Release();
         }
     }
 };