C# 如何读取c++ dll中的指针数据

这是c++ 编写的dll 函数原型
int __stdcall ReadCard(uchar d12,uchar *buffData)
其中 *buffData是返回的数据字符串 这是个指针
请问 在C#中如何获取这个指针返回的数据

假设d12是buffdata的长度,假设实现如下:
while (d12--)
*(buffData + d12) = 'a';
return 1;
C#中只需要声明如下:
[DllImport("xxx.dll")]
private static extern int ReadCard(byte d12, ref byte buffData);
使用如下:
byte[] d = new byte[10];
ReadCard((byte)d.length, ref d[0]);
温馨提示:答案为网友推荐,仅供参考
相似回答