【发布时间】:2016-03-17 10:04:23
【问题描述】:
在我的 C/C++ 库中,我有一个具有这样一个原型的函数:
long myFunction( const wchar_t*& pszOutput)
Dll 为 pszOutput 分配内存并释放它。
如何从 C# 调用这个函数?
我已经尝试了以下行的很多变体(没有 out,使用 MarshalAs,...),但退出 myFunction 时总是崩溃:
[DllImport("mydll.dll", EntryPoint = "myFunction", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Unicode)]
private static extern long myFunction(ref string szOutput);
有谁知道,该怎么做?
【问题讨论】: