Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / November 2005

Tip: Looking for answers? Try searching our database.

Bypassing the CCW

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Eric St-Onge - 02 Nov 2005 22:00 GMT
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

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.