如何在窗口消息过程中使用IntPtr
DLL, Win32 Code
int* rgbptr = NULL;
::SendMessage(_mainHandle, HM_GETSUBPIC, 0, (LPARAM)&rgbptr);
EXE, CLR Code
void Form1::WndProc(Message% m){
switch ( m.Msg )
{
case HM_GETSUBPIC:
{
Bitmap^ bmp = this->form2->GetPictureboxImg();
Rectangle rect = Rectangle(0,0,bmp->Width,bmp->Height);
// Lock the bitmap's bits.
Imaging::BitmapData^ bmpData = bmp->LockBits( rect, Imaging::ImageLockMode::ReadWrite, bmp->PixelFormat );
// Get the address of the first line.
IntPtr ptr = bmpData->Scan0;
// Declare an array to hold the bytes of the bitmap.
// This code is specific to a bitmap with 24 bits per pixels.
int bytes = bmpData->Stride * bmp->Height;
// 请问,怎么把这段内存赋给DLL里的rgbptr指针??
// Unlock the bits.
bmp->UnlockBits( bmpData );
break;
}