我有以下C++函数,我将在C#中使包装函数:
byte* FunctionReturnVectorPoint()
{
return vectorPoint;
}
我是这样尝试的:
[DllImport("DLL_NAME.dll", CallingConvention = CallingConvention.ThisCall)]
unsafe public static extern byte*[] FunctionReturnVectorPoint();
但它不起作用。
您有什么建议吗?
最佳答案
解决了:
[DllImport("DLL_NAME.dll", CallingConvention = CallingConvention.ThisCall)]
public static extern IntPtr FunctionReturnVectorPoint();
并以这种方式调用该函数:
IntPtr tempPoint = FunctionReturnVectorPoint();
byte[] vector= new byte[dimensionVector];
Marshal.Copy(tempPoint , vector, 0, dimensionVector);