繁体   English   中英

将ac dll函数导入c#

[英]importing a c dll function into c#

我正在尝试使用来自未管理的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不对。 这样做的正确方法是什么?

它应该与ushort []一起使用

[DllImport("cDLLfile.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true) ]
private static extern short Function(ushort a, UInt32 b, UInt32 c, ushort[] buffer);

尝试这个:

extern short Function(ushort a, UInt32 b, UInt32 c, ushort[] buffer)

在这里,您将找到有关封送数组的详细信息和示例代码。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM