first look up CoMarshalInterThreadInterfaceInStream in msdn,it use CoGetInterfaceAndReleaseStream to unmarshal Interface in the stream.
then you now how to do.
1. create a IStream ,do not write something in it
eg.
::CoInitialize(NULL);
HRESULT hr;
CComPtr<IStream> pStream;
hr=pStream.CoCreateInstance(CLSID_Stream);
2.then marshal your own interface to the stream
hr=CoMarshalInterThreadInterfaceInStream(IID_YOUWANT_MARSHAL_INTERFACE,pYourObj,pStream);
if hr=0,then you can pass the pStream to the other thread
3.unmarshal you obj from the stream
eg.
UINT Myfunc(void p)
{
//if the p is the stream pointer
CComPtr<IID_YOUWANT_MARSHAL_INTERFACE> pYourObj;
hr=CoGetInterfaceAndReleaseStream((IStream*)p
,IID_YOUWANT_MARSHAL_INTERFACE,(void**)pYourObj);
//the you have the pointer to you obj in the other thread,do not care about the release of IStream p
}
I just use the two function pass interface pointer cross thread and not test cross process ,that's long long ago and the source code is lost.this code maybe contain error because i write it here not copy it to here.the stream implement you can find in many component.eg the ado .to use it just use
#import "C:\Program Files\Common Files\System\ado\msado15.dll" named_guids,rename("EOF","adoEOF")
using namespace ADODB;