如果读取C++里面的byte*
有一个C++写的函数 int Read(char* input , int len, byte*[] out)
请问如何在C#里在DllImport以后如何调用?
谢谢
------解决方案--------------------ref byte[]可以嘛?
------解决方案--------------------public static extern int Read(string input , int len, StringBuilder sb)
注意传进去前给StringBuilder 分配好做够空间,如
StringBuilder sb = new StringBuilder (255);
------解决方案--------------------byte[]
调用示例:
[DllImport("LsdSle4442.dll", SetLastError = true, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern Int32 _ReadCard(byte[] S); //读卡
------解决方案-------------------- byte[] buf;
buf = new Byte[255];
int n = _ReadCard(buf);
string s = Encoding.GetEncoding("GB2312").GetString(buf);
//string s = Encoding.Default.GetString(buf);
MessageBox.Show(s);