日期:2014-05-17 浏览次数:20815 次
int __stdcall fun(unsigned char *srcdata, int *number, unsigned char *tagdata[4]) ;
int number = 4;
byte[,] result = new byte[4, 100];
IntPtr[] ptArray = new IntPtr[4];
ptArray[0] = Marshal.AllocHGlobal(100);
ptArray[1] = Marshal.AllocHGlobal(100);
ptArray[2] = Marshal.AllocHGlobal(100);
ptArray[3] = Marshal.AllocHGlobal(100);
fucn(buf, ref number, ptArray); // 调用
for (int i = 0; i < number; i++)
{
for (int j = 0; j < 100; j++)
{
byte b = 0;
b = (byte)Marshal.PtrToStructure((IntPtr)((UInt32)ptArray[i] + j), b.GetType());
result[i, j] = b;
}
}
Console.WriteLine();
Marshal.FreeHGlobal(ptArray[0]);
Marshal.FreeHGlobal(ptArray[1]);
Marshal.FreeHGlobal(ptArray[2]);
Marshal.FreeHGlobal(ptArray[3]);