C#调用明华读写器mwrf32.dll读写问题

lu807160015 2012-04-25 10:45:22
//--初始化
[DllImport("mwrf32.dll")]
//HANDLE __stdcall rf_init(__int16 port,long baud);
public static extern IntPtr rf_init(Int32 port, Int32 baud);

//寻卡
[DllImport("mwrf32.dll", EntryPoint = "rf_request")]
//__int16 __stdcall rf_request(HANDLE icdev,unsigned char _Mode,unsigned __int16 *TagType);
public static extern int rf_request(IntPtr icdev,Byte _Mode, ref UInt16 TagType);

IntPtr icdev = rf_init(0, 115200); //初始化正确
UInt16 TagType = 0;
int st = -1;
st = rf_request(icdev, 1, ref TagType);
if (st != 0)
{
MessageBox.Show("寻卡失败");
return;
}
为什么卡放在读写器上始终显示“寻卡失败”,请高手们指点指点
...全文
336 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
小志 2012-04-25
  • 打赏
  • 举报
回复
mizuho_2006 2012-04-25
  • 打赏
  • 举报
回复
rf_request返回的是byte数组,前几天搞这个遇到和楼主同样的问题,现在已经弄好了
你将返回值改为byte类型就可以了

public static extern byte rf_request(IntPtr icdev,Byte _Mode, ref UInt16 TagType);

lu807160015 2012-04-25
  • 打赏
  • 举报
回复
问题我自己已经解决,是int rf_request -改成int16就行了,数据格式问题,谢谢你们

110,535

社区成员

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

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

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