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
