问下这两个API在C#中该如何申明

cnwolfs 2012-05-27 04:53:24
int __stdcall LPC2400_ReadData (int siPipeNum,unsigned char *pucRcvBuf,int siReadLen,int siWaitTime)

int __stdcall LPC2400_WriteData(int siPipeNum,unsigned char *pucSendBuf,int siSendLen,int siWaitTime)


我的写法是:
[DllImport("EasyUSB2400.dll", EntryPoint = "LPC2400_ReadData", SetLastError = true, CharSet = CharSet.Unicode, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
private static extern int LPC2400_ReadData(int siPipeNum, ref byte[] pucRcvBuf, int siReadLen, int siWaitTime);

[DllImport("EasyUSB2400.dll", EntryPoint = "LPC2400_WriteData", SetLastError = true, CharSet = CharSet.Unicode, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
private static extern int LPC2400_WriteData(int siPipeNum, ref byte[] pucSendBuf, int siSendLen, int siWaitTime);

不过貌似是没成功,可以编译通过,也可以运行,但是Read取不到数据。



...全文
90 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
cnwolfs 2012-06-15
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 的回复:]
ref byte[] pucRcvBuf
[/Quote]

这个正解,多谢,不好意思,结迟了,忘记了
ParanoidKing 2012-05-27
  • 打赏
  • 举报
回复
char *用StringBuilder去读试试
gomoku 2012-05-27
  • 打赏
  • 举报
回复
ref byte[] pucRcvBuf

110,561

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧