繁体   English   中英

C ++到C#dll导入ReadImage

[英]c++ to c# dll import ReadImage

我在C ++中有此功能,我想在C#中将其导入

BS_RET_CODE BS_ReadImage( int handle, int imageType, unsigned char* bitmapImage, int* imageLen)

我试过了

[DllImport("BS_SDK.dll",CharSet = CharSet.Ansi, EntryPoint = "BS_ReadImage")]
public static extern int BS_ReadImage(int handle, int imageType, IntPtr bitmapImage, ref int imageLen);

IntPtr image = new IntPtr();
int len = 0;
BSSDK.BS_ReadImage(m_Handle, 0xff, image, ref len);

byte[] _imageTemp = new byte[len];
Marshal.Copy(image, _imageTemp, 0, len);

但我收到访问冲突异常

也许您应该检查len实际上是否等于或大于image的大小?

异常在哪里发生? 到底是哪条线?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM