Hi,
I have a DLL that exposes COM interfaces.
One of the COM Object receives an IDispatch pointer. I know that this
IDispatch pointer is in fact a COM Callable Wrapper for a
System::Drawing::Bitmap object. How can I get a reference to the .NET Bitmap,
bypassing the CCW?
ex:
HRESULT MyMethod( IDispatch* _CCWOfBitmap )
{
System::Drawing::Bitmap* dotnetBitmap = MagicMethod( _CCWOfBitmap );
System::Drawing::Color myColor = dotnetBitmap->GetPixel(1,1);
// ... continuing enjoying .NET here...
}
Question: MagicMethod should do what to make this code working?
Thanks
Eric
Marcus Heege - 05 Nov 2005 20:26 GMT
Try Marshal::GetComInterfaceForObject
> Hi,
>
[quoted text clipped - 19 lines]
> Thanks
> Eric
Eric St-Onge - 07 Nov 2005 13:56 GMT
Hi,
Thanks for quick reply...
How's this solve my problem since I receive a COM interface and want a .NET
Object? This API is actually the other way around from my understanding (it
returns an IntPtr).
In the sample bellow I need a replacement for MagicMethod with return a
reference to a .NET object...
Eric
> Try Marshal::GetComInterfaceForObject
>
[quoted text clipped - 21 lines]
> > Thanks
> > Eric
Nishant Sivakumar - 08 Nov 2005 18:38 GMT
Have you looked at Marshal::GetTypedObjectForIUnknown?

Signature
Regards,
Nish [VC++ MVP]
> Hi,
>
[quoted text clipped - 19 lines]
> Thanks
> Eric