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
c# 调用 c++的 dll 中关于 char*传入传出参数
原文:https://www.cnblogs.com/bigfi/p/12521958.html