I currently have an array of System::Drawing::Bitmaps
in a dll in managed C++ code. I would like to be able to call into the method in the managed C++ from unmanaged(native) C++. The question is how to do I pass the array back to unmanaged C++?
I can call GetHbitmap()
on the managed C++ bitmap which returns an IntPtr
. Should I pass an array of IntPtrs? Not quite sure the best way to do this. So to be clear I have this:
Managed C++ Method:
void GetBitmaps(<????>* bitmaps)
{
//Calling into C# to get the bitmaps
array<System::Drawing::Bitmap^>^ bmp=ct->DataGetBitmaps(gcnew String(SessionID));
for(int i=0;i<bmp.Length;i++)
{
System::Drawing::Bitmap^ bm=(System::Drawing::Bitmap^)bmp.GetValue(i);
IntPtr hBmp=bm->GetHbitmap();
}
//So now how to I convert the hBmp to an array value that I can then pass back to unmanaged C++(hence the <????> question for the type)
}
Is an array of HBITMAPS? And if so how can you convert the IntPtr
hBmp to that array?
The managed C++ code works all well and good and correctly gets the array of bitmaps. but now I need to get those bitmaps back to the unmanaged C++ when the unmanaged C++ calls into the GetBitmaps method. I don't know what type of variable I should be passing in and then once I pass it in, what do I do to convert it to a type that unmanaged C++ can use?