.NET - 从非托管数组非托管数组复制

问题描述:

我一直在寻找通过Marshal类,但我似乎无法找到一种方法,让我从一个非托管阵列(IntPtr的)复制到其他非托管阵列(IntPtr的)。

I've been looking through the Marshal class, but I can't seem to find a method that allows me to copy from an unmanaged array (IntPtr) to another unmanaged array (IntPtr).

这是使用.NET可能吗?

Is this possible using .NET?

您还可以的DllImport RtlMoveMemory来完成这项工作:

You can also DllImport RtlMoveMemory to get the job done:

[DllImport("Kernel32.dll", EntryPoint="RtlMoveMemory", SetLastError=false)]
static extern void MoveMemory(IntPtr dest, IntPtr src, int size);

这也将需要FullTrust的,但是,但是当你正在使用非托管code,我希望你已经拥有了它。

This will also require FullTrust, however, but as you are working with unmanaged code, I'd expect you already have it.