c++的dll接口原型为:int CheckSN(const char* InfoList, char* msg);
c#调用转换为:
[DllImport("sncplusInterface.dll", EntryPoint = "CheckSN", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
public static extern int CheckSN(string InfoList, StringBuilder msg);
调用为:
StringBuilder chOutMsg = new StringBuilder(1024);
CheckSN(chData, chOutMsg/*ref chOutMsg*/);
string str = chOutMsg.ToString();
用ref 或 out关键字会crash