object address

  • Thread starter Thread starter Weimin Zhang
  • Start date Start date
W

Weimin Zhang

I have a problem to pass an address of a control to a
function under C# .net 2003. The control is loaded on a
windows form, but the control is an OCX (COM component).
The function is in a C++ static dll (like an API
function),and the function expects a long (32 bit)
variable for an address. I could call it from VB 6 by
passing the control address using the VB's function
ObjPtr and it works fine. But in C#, you can't pass the
object name (reference) as its address,nor you
couldgetthe addressof it. Can anybody help me to find a
solution on it? Thanks.
 
Try this

IntPtr pUnk = Marshal.GetIUnknownForObject( YourControl.GetOcx() );
// call external function here and pass in pUnk
Marshal.Release( pUnk );



Mattias
 
Back
Top