unsafe class MyDll
{
[System.Runtime.InteropServices.DllImport("Comm.dll")]
public static extern fun(byte* x);
}...
unsafe
{
...
byte* buf = stackalloc byte[100];
MyDll.fun(buf);
byte[] r = /* buf[6] ~ buf[17] 是我想要的数据,怎么弄出来? */
...
}
{
[System.Runtime.InteropServices.DllImport("Comm.dll")]
public static extern fun(byte* x);
}...
unsafe
{
...
byte* buf = stackalloc byte[100];
MyDll.fun(buf);
byte[] r = /* buf[6] ~ buf[17] 是我想要的数据,怎么弄出来? */
...
}
{
r[i]=buf[6+i];
}
public static extern fun(byte[] x);
unsafe
{
byte[] buffer = new byte[100];
fixed (byte* buf = buffer)
{
MyDll.fun(buf);
}
//buffer就是想要的数据
}
class MyDll
{
[System.Runtime.InteropServices.DllImport("Comm.dll")]
public static extern fun(byte[] x);
}... ...
byte[] buf = newc byte[100];
MyDll.fun(buf);
用buf吧