日期:2014-05-18 浏览次数:20731 次
IPC_Login(char* CamerIP,int dataer);
------解决方案--------------------
IPC_Login(char* CamerIP,int dataer);
------解决方案--------------------
C#里有提供一个专门用于平台指针调用的类型 Inptr 再用System.Runtime.InteropServices.Marshal类的方法进行转换,例如:
[System.Runtime.InteropServices.DllImport("Encrypt1.dll", CharSet = System.Runtime.InteropServices.CharSet.Ansi, CallingConvention = System.Runtime.InteropServices.CallingConvention.Cdecl)] public static extern IntPtr Encode(IntPtr message);//这里相当于C++的char* string msg = "aksdjfk"; IntPtr inPtr = System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi(msg); IntPtr outPtr = Common.Encrpty.Encode(inPtr); string msg1 = System.Runtime.InteropServices.Marshal.PtrToStringAnsi(outPtr);