Q
Qindong Zhang
I get my memory address (Pointer) from an API call, and then pass this
address to DrawDibDraw function, it works fine on Windows 2000, but
not works on Windows XP (get green screen).
Here something interesting;
I copy the content of the pointer to byte array (Use Marshal.Copy &
intPtr), then create a new pointer from byte array (Use
Marshal.UnsafeAddrOfPinnedArrayElement) it works in Windows XP.
Why? Thanks.
' m_ImagePtr come from an API call.
' This does not work in Windows XP, but works in Windows 2000.
DrawDibDraw(xx, hc, .., m_ImagePtr, 0, 0, 0)
////////////////////////////////////////////
' This works in Windows XP
Dim m_data As Byte()
Dim tmpLength As Integer = 12345
ReDim m_data(tmpLength - 1)
Dim newPtr As New IntPtr(m_ImagePtr)
Marshal.Copy(newPtr, m_data, 0, m_data.Length)
Dim ImagePtr As Integer
ImagePtr = Marshal.UnsafeAddrOfPinnedArrayElement(m_data, 0).ToInt32
DrawDibDraw(xx, hc, .., ImagePtr, 0, 0, 0)
address to DrawDibDraw function, it works fine on Windows 2000, but
not works on Windows XP (get green screen).
Here something interesting;
I copy the content of the pointer to byte array (Use Marshal.Copy &
intPtr), then create a new pointer from byte array (Use
Marshal.UnsafeAddrOfPinnedArrayElement) it works in Windows XP.
Why? Thanks.
' m_ImagePtr come from an API call.
' This does not work in Windows XP, but works in Windows 2000.
DrawDibDraw(xx, hc, .., m_ImagePtr, 0, 0, 0)
////////////////////////////////////////////
' This works in Windows XP
Dim m_data As Byte()
Dim tmpLength As Integer = 12345
ReDim m_data(tmpLength - 1)
Dim newPtr As New IntPtr(m_ImagePtr)
Marshal.Copy(newPtr, m_data, 0, m_data.Length)
Dim ImagePtr As Integer
ImagePtr = Marshal.UnsafeAddrOfPinnedArrayElement(m_data, 0).ToInt32
DrawDibDraw(xx, hc, .., ImagePtr, 0, 0, 0)