How to get the pointer of a COM control interface ?

G

Guest

Hello Gurus;

I have some strange, complicated and challenging question.
This question may show a poor design, and I agree it very poor. But I have
some constrainment that must be handled as I'll show in here (you know...
plaster/banded...):

I have a C# Form with a COM/OCX control (unmanaged...).
I need to get the pointer for a specific interface of the COM control to be
used in another C++ DLL (with clr support), and in the C++ to use an
unmanaged/native code to access the COM control.
In this COM control interface there is a function that only exist in the
specific interface. I need to invoke this com function in a native syntax
from the C++ DLL (unmanaged code) directly to the COM control interface (also
unmanaged).

I need to do that because the C++ DLL has a lot of data that need to be send
to the COM control. But if this data will be sent to the COM control through
the .NET application (managed part), the data will be copied (memory copy)
from the unmanaged code to the managed code, and again from the managed code
to the unmanaged COM control.
I wish to avoid this data copy by letting the C++ component set the data
directly to the COM control (unmanaged to unmanaged = NO copy!).
Note that the control in instantiated in the .NET/C++ application which in
managed.


How can I do that in the .NET/C# side and in the C++ side?


- - - -
Thanks
Sharon
 
M

Mattias Sjögren

I need to get the pointer for a specific interface of the COM control to be
used in another C++ DLL (with clr support), and in the C++ to use an
unmanaged/native code to access the COM control.

AxHost.GetOcx() will give you a reference to the actual native control
object. From there you can can cast to whatever interface you want.


Mattias
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top