C#调用明华读写器mwrf32.dll读写问题
//--初始化
[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;
}
为什么卡放在读写器上始终显示“寻卡失败”,请高手们指点指点
------解决方案--------------------
rf_request返回的是byte数组,前几天搞这个遇到和楼主同样的问题,现在已经弄好了
你将返回值改为byte类型就可以了
public static extern byte rf_request(IntPtr icdev,Byte _Mode, ref UInt16 TagType);
------解决方案--------------------
C++数据类型与C#对应关系
http://blog.163.com/xiaozhi797@126/blog/static/62440288201231341344512/