|8. To marshall an interface pointer from the owning thread to a another thread, use the CoMarshalInterThreadInterfaceInStream() and the CoGetInterfaceAndReleaseStream() APIs.
9. Note that marshalling an interface pointer is just one-half of the game. The other half, which in many ways is more challenging and interesting, involves the marshalling of the PARAMETERS of the interface methods.
10. If you make your interface dual or IDispatch-based, the marshalling of the methods' parameters is performed completely automatically for you curtesy of COM.
11. This is logical because dual and IDispatch interfaces can use only OLE Automation-Compatible Types for parameters (e.g. VARIANTs, BSTRs, etc). COM has already prepared itself to marshall these types of parameters.
12. Non-dual and non-IDispatch based interfaces (aka Custom Interfaces) must provide their own custom marshalling. Proxy and stub DLLs must be created for this purpose.
13. Note also that dual and IDispatch based interfaces also use a proxy/stub DLL to perform parameter marshalling. This proxy/stub DLL is the famous oleaut32.dll (read it as OLE AUTomation 32 DLL).
14. To determine or confirm if your interface uses oleaut32.dll to marshall parameters, look up the registry entry of your Interface, e.g. :
Here you will find a "ProxyStubClsid32" subkey. It should have a "Default" string value. The value is the CLSID of the object that implements the marshalling functionality of your interface.
15. Look up the registry entry for this CLSID and you will see the in-proc server DLL of the marshalling object. If your interface is dual or IDispatch based, the CLSID should be :
If you look up this CLSID entry in the registry, i.e. :
you will find the following information :
15.1 The default string value for this CLSID is "PSOAInterface" (read this as Proxy Stub OLE Automation Interface). PSOAInterface is the "universal marshaler" that creates in-memory COM stub/proxy pairs based on type library information. PSOAInterface is oleaut32's tool that enables VB to do "somewhat native" COM marshaling by mimicking the functionality of "midl /Oicf" on-the-fly. PSOAInterface builds and caches native COM proxies based on type libraries. The downside of PSOAInterface is that it requires interfaces that use it to be OLE-Automation compatible, that is, it must return HRESULTs and its parameters must be OLE-Automation types, since that is what it was built for and that's the set of types that COM type libraries can express.
15.2 There is an "InprocServer32" subkey. In this subkey, you will find that the default string value is "oleaut32.dll".
We hope the above information will be useful to all. There's still quite alot of information to share with all on this same topic. We'll be updating this Knowledge Sharing Article with a Part 2 soon.