// Define the istream which stores marshalled interface pointer
IStream* iStream;
IStream* iStream;
// Marshal the pointer in one thread
hResult = CoMarshalInterThreadInterfaceInStream (__uuidof(InterfaceClass), spInterfacePointer, &iStream);
hResult = CoMarshalInterThreadInterfaceInStream (__uuidof(InterfaceClass), spInterfacePointer, &iStream);
// Unmarshal and get the interface pointer in another thread
hResult = CoGetInterfaceAndReleaseStream (iStream, __uuidof(InterfaceClass), (void**)&spInterfacePointer);
hResult = CoGetInterfaceAndReleaseStream (iStream, __uuidof(InterfaceClass), (void**)&spInterfacePointer);
转载于:https://blog.51cto.com/yongkai/305086