tags:

views:

36

answers:

2

If I receive a interface pointer present in the other apartment than the current, I am required to Marshal it at the sending apartment side and Un-marshal it at the receiving side. On interface pointer thus received can I do a QueryInterface? If I did the QueryInterface, is the pointer thus received is a usable interface pointer or does require any marshaling again?

Thanks F

+2  A: 

You can do a QueryInterface and it will return already marshaled interface pointer (because you call QueryInterface not on a real object but on a proxy object).

Sergius
Thank you very much Sergius for your reply.
coolcake
+1  A: 

Yes, you can call any methods on the interface, QueryInterface() included. The proxy will behave exactly the same way as if it was a real object - it will just forward all method calls to the real object. Whenever any method you called on a proxy returns a pointer that pointer is already marshalled (or you receive an error code if it can't be marshalled) and then unmarshalled on your side which could lead to another proxy being created. So when you call QueryInterface() you receive an already unmarshalled pointer to a proxy.

sharptooth
Thank you very much for your reply.
coolcake
You are saying that proxy object will be created, suppose the interface for which we are marshalling is a COM object occupying lots of memory and resources, will this proxy getting created does cause to occupy the same set of resources and memory again?
coolcake
No, a proxy is a lightweight object - it doesn't duplicate the real object, it only forwards the calls to the real object. For examle you might have a file handle in the real object - but the proxy has no idea of that, it only knows the real object's interface and how to forward calls.
sharptooth