【发布时间】:2010-12-28 04:25:57
【问题描述】:
我正在尝试从未管理的 C dll 中使用 C# 中的函数。我是 C# 新手,不确定我是否正确执行此操作。 C 中的函数看起来像这样:
unsigned short Function(unsigned short, unsigned long, unsigned long, unsigned short*);
[DllImport("cDLLfile.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
private static extern short Function(ushort a, UInt32 b, UInt32 c, IntPtr buffer);
缓冲区是一个类似的数组
ushort[] = new ushort[7];
我填充了数组,然后尝试将其传递给 Function 并收到错误。我知道 IntPtr 是不对的。这样做的正确方法是什么?
【问题讨论】:
-
你能发布你得到的错误吗?