1

I wrote two small C++ applications, one of which is an ActiveX container embedding some ActiveX control. This container application knows the IUnknown* referencing the ActiveX control.

The other application is a client which shall interact with the ActiveX control in the former application. However, I don't know how to get a handle on the control in the client application. Simply transporting the pointer value of the IUnknown* from the server to the client won't work of courses due to independant address spaces.

Is it somehow possible to "duplicate" a handle to some COM object so that the newly created handle can be used by other processes? I'd like to have COM do the RPC work for me. Otherwise, I'd need to do all COM calls in the server application and do all the RPC myself. :-/

Frerich Raabe
  • 81,733
  • 18
  • 105
  • 196
  • Check out answer to this similar qu: http://stackoverflow.com/questions/5425770/in-proc-com-object-sharing-across-another-process/5431017#5431017 – BrendanMcK Apr 14 '11 at 17:58

1 Answers1

2

You may want to look at RPC in general, and COM Proxies.

A proxy resides in the address space of the calling process and acts as a surrogate for the remote object. From the perspective of the calling object, the proxy is the object. Typically, the proxy's role is to package the interface parameters for calls to methods in its object interfaces. The proxy packages the parameters into a message buffer and passes the buffer onto the channel, which handles the transport between processes. The proxy is implemented as an aggregate, or composite, object. It contains a system-provided, manager piece called the proxy manager and one or more interface-specific components called interface proxies. The number of interface proxies equals the number of object interfaces that have been exposed to that particular client. To the client complying with the component object model, the proxy appears to be the real object.

ta.speot.is
  • 25,998
  • 8
  • 62
  • 93
  • This looks very interesting, but I find it hard to locate more relevant documentation. Do you maybe know how I can easily create a proxy object in a calling process for some given `IUnknown*` in a called process? – Frerich Raabe Apr 14 '11 at 11:00
  • http://msdn.microsoft.com/en-us/library/ms692621(v=vs.85).aspx - "In the case of most COM interfaces, the proxies and stubs for standard marshaling are in-process component objects which are loaded from a systemwide DLL provided by COM in Ole32.dll." – ta.speot.is Apr 14 '11 at 11:28
  • I might be dense, sorry - do you know what API to use to a) uniquely identify some COM object and b) use this unique ID in another process to create a proxy object which does the RPC? – Frerich Raabe Apr 14 '11 at 11:58
  • 1
    Ah, it seems `CoMarshalInterface` and `CoUnmarshalInterface` are what I need! – Frerich Raabe Apr 14 '11 at 12:21