有时候c#需要调用 c++dll 参数为字符串且为输出的函数 。
如: c++ dll函数如下:
int test(char _OUT *str);
c#中调用如下:
[DllImport("test.dll", CallingConvention = CallingConvention.Cdecl)]
public extern static int test(StringBuilder str);
public string test()
{
string list;
StringBuilder lp;
lp = new StringBuilder(100);
int ret=test(lp);
list = lp.ToString();
return list;
}