void Call(int *count, Rect **arr)
{
//…..
//重新Malloc一段内存,指针复制给入参,外部调用前并不知道长度,另外提供接口Free内存
//….
}
Struct Rect
{
int x;
int y;
int width;
int height;
};
Struct Rect
{
public int x;
public int y;
public int width;
public int height;
}
[DllImport("xxx.dll", EntryPoint = "Call", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern void Call(
ref int count,
ref IntPtr pArray);
IntPtr pArray = IntPtr.Zero; //数组指针
int count = 0;
Call(ref count, ref pArray);
var rects = new Rect[count]; //结果数组
for (int i = 0; i < count; i++)
{
var itemptr = (IntPtr)((Int64)Rect + i * Marshal.SizeOf(typeof(Rect))); //这里有人用的UInt32,我用的时候溢出了,换成Int64
rects[i] = (Rect)Marshal.PtrToStructure(itemptr, typeof(Rect));
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有