[Quote=引用 12 楼 yanlongwuhui 的回复:]
结构体改下:
Public Structure Bitmap
Dim bmType As Integer
Dim bmWidth As Integer
Dim bmHeight As Integer
Dim bmWidthBytes As Integer
Dim bmPlanes As short
Dim bmBitsPixel As short
Dim bmBits As Integer
End Structure
[/Quote]
结构体改下:
Public Structure Bitmap
Dim bmType As Integer
Dim bmWidth As Integer
Dim bmHeight As Integer
Dim bmWidthBytes As Integer
Dim bmPlanes As short
Dim bmBitsPixel As short
Dim bmBits As Integer
End Structure
[Quote=引用 9 楼 yanlongwuhui 的回复:]
Public Declare Function GetGDIObject Lib "gdi32.dll" Alias "GetObjectA" (ByVal hObject As Integer, ByVal nCount As Integer, ByRef lpObject As Bitmap) As Integer
Public Declare Function GetGDIObject Lib "gdi32.dll" Alias "GetObjectA" (ByVal hObject As Integer, ByVal nCount As Integer, ByRef lpObject As Bitmap) As Integer
我放一个PictureBox,并初始化一张图片
Public Declare Function GetGDIObject Lib "gdi32.dll" Alias "GetObjectA" (ByVal hObject As Long, ByVal nCount As Long, ByRef lpObject As Bitmap) As Long
Public Structure Bitmap
Dim bmType As Long
Dim bmWidth As Long
Dim bmHeight As Long
Dim bmWidthBytes As Long
Dim bmPlanes As Integer
Dim bmBitsPixel As Integer
Dim bmBits As Long
End Structure
Dim Bmp As Bitmap
GetGDIObject(PictureBox.Handle, Len(Bmp), Bmp)
执行最后一句时提示:
A call to PInvoke function 'ImageApp!ImageApp.Form1::GetGDIObject' has unbalanced the stack.
This is likely because the managed PInvoke signature does not match the unmanaged target signature.
Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.
但是我用PictureBox.Handle,出现如下错误:
A call to PInvoke function 'ImageApp!ImageApp.Form1::GetGDIObject' has unbalanced the stack.
This is likely because the managed PInvoke signature does not match the unmanaged target signature.
Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.