下面是在网路上找到的资料,可以透过dllimport的MSVCRT.DLL达到的memcpy的功能[DllImport("msvcrt.dll", EntryPoint = "memcpy", CallingConvention = CallingConvention.Cdecl, SetLastError = false)]public static extern IntPtr memcpy(IntPtr dest, IntPtr src, UIntPtr count);
----------------------------------------------------------------可是,实际上却不知道要如何应用不知道有没有人可以提供一个很简单的范例呢?
----------------------------------------------------------------可是,实际上却不知道要如何应用不知道有没有人可以提供一个很简单的范例呢?
[DllImport("msvcrt.dll", EntryPoint = "memcpy", CallingConvention = CallingConvention.Cdecl, SetLastError = false)] public static extern IntPtr memcpy(IntPtr dest, IntPtr src, UIntPtr count); public Form1()
{
InitializeComponent(); UIntPtr c = new UIntPtr(2);
IntPtr[] sbs = new IntPtr[2];
sbs[0] = Marshal.StringToHGlobalAnsi("aaa1");
sbs[1] = Marshal.StringToHGlobalAnsi("vvv2");
memcpy(sbs[0], sbs[1], c);
MessageBox.Show("" + Marshal.PtrToStringAnsi(sbs[0]) + " " + Marshal.PtrToStringAnsi(sbs[1]));
}