Reputation: 621
I have a Dll and the header file for it, and I'm trying to create a COM wrapper in C++ to use in C#.
For most of functions it was very simple since they were returning int
or string
.
I have this struct in the header file.
virtual HRESULT STDMETHODCALLTYPE GetBMP(
int Width,
int Height,
HBITMAP *Bitmap) = 0;
My problem is that since I'm way out of my league with C++ I don't know how to convert the HBITMAP
to something more appropriated to .net style
Thanks in advance, and please forgive me if wrote stupid things
UPDATE: I tried something like this :
HBITMAP GetBMP(int Width, int Height)
{
HBITMAP bm = 0;
m_piHelper->GetBMP(Width,Height,&bm);
return bm ;
}
The problem obviously is after that in c# how convert from 'HBITMAP__*' to 'System.IntPtr to use it with bitmap.fromHbitmap
Upvotes: 0
Views: 1081
Reputation: 78135
The parameter should be out IntPtr
.
Then you can create an additional function that will call GetBMP
and then call Bitmap.FromHbitmap
to return a bitmap. Such function must then DeleteObject
the original hbitmap
.
Upvotes: 1