c# 调用c dll void 指针类型转化问题

2025-02-25 21:18:31
推荐回答(2个)
回答1:

//用IntPtr,下面是结构体转换到IntPtr方式

Point p;//要传的结构体
int size=System.Runtime.InteropServices.Marshal.SizeOf(p);
IntPtr p=System.Runtime.InteropServices.Marshal.AllocHGlobal(size);
System.Runtime.InteropServices.Marshal.StructureToPtr(p, p, true);

回答2:

试试 System.IntPtr。