110,561
社区成员
发帖
与我相关
我的任务
分享
//寻卡
[DllImport("mwhrf_bj.dll", EntryPoint = "rf_card")]
public static extern Int16 rf_card(int icdev, char _Mode, Int16* _Snr);
//将密码装入读写模块RAM中
[DllImport("mwhrf_bj.dll", EntryPoint = "rf_load_key")]
public static extern int rf_load_key(int icdev, char _Mode, char _SecNr, Byte* _NKey);
//将密码装入读写模块RAM中
[DllImport("mwhrf_bj.dll", EntryPoint = "rf_load_key_hex", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
public static extern int rf_load_key_hex(int icdev, char _Mode, char _SecNr, Byte* _NKey);
byte[] tk = new byte[6] { 255, 255, 255, 255, 255, 255 };
fixed (byte* array = tk)
if ((IC.rf_load_key_hex(icdev, '0', '1', array)) != 0)
{
MessageBox.Show("Load key error!!");
IC.Close_USB(icdev); //关闭设备
return;
}
int checkIC_pwd = IC.rf_authentication(icdev, 0, 1);
if (checkIC_pwd != 0)
{
MessageBox.Show("IC卡密码错误!");
IC.Close_USB(icdev); //关闭设备
return;
}
[DllImport("mwhrf_bj.dll", EntryPoint = "rf_authentication")]
public static extern int rf_authentication(int icdev, int mode, int SecNr);
//读取数据
[DllImport("mwhrf_bj.dll", EntryPoint = "rf_read")]
public static extern Int16 rf_read(int icdev, int Adr, ref Byte[] Data);
Byte[] str = new Byte[16];
string strrr = "";
int read = -1;
read = IC.rf_read(icdev, 2,ref str);
strrr = Encoding.Default.GetString(str);
if (read == 0)
MessageBox.Show("IC卡中数据读取成功!" + strrr.ToString());
else
MessageBox.Show("IC卡中数据读取失败!" + strrr.ToString());
//读取数据
[DllImport("mwhrf_bj.dll", EntryPoint = "rf_read")]
public static extern int rf_read(int icdev, int _Adr, ref Byte[] _Data);
[DllImport("mwrf32.dll", EntryPoint = "rf_load_key_hex")]
public static extern Int16 rf_load_key_hex(int icdev, int mode, int secnr, string keybuff);
int ints=IC.rf_load_key_hex(icdev, 0, 1, "a0a1a2a3a4a5");
byte[] tk = new byte[6] { 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5 };
int ints=IC.rf_load_key_hex(icdev, 0, 1, tk);
if (ints != 0)
{
MessageBox.Show("Load key error!!");
}
[DllImport("mwrf32.dll", EntryPoint = "rf_load_key_hex", SetLastError = true,
CharSet = CharSet.Auto, ExactSpelling = false,
CallingConvention = CallingConvention.StdCall)]
public static extern Int16 rf_load_key_hex(int icdev, int mode, int secnr, [MarshalAs(UnmanagedType.LPArray)]byte[] keybuff);
//连接设备
[DllImport("mwhrf_bj.dll", EntryPoint = "Open_USB")]
public static extern int Open_USB();
//断开设备
[DllImport("mwhrf_bj.dll", EntryPoint = "Close_USB", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
public static extern int Close_USB(int icdev);
//获取设备版本号
[DllImport("mwhrf_bj.dll", EntryPoint = "rf_get_status")]
public static extern int rf_get_status(int icdev, Byte[] version);
//蜂鸣器
[DllImport("mwhrf_bj.dll", EntryPoint = "rf_beep", SetLastError = true, CharSet = CharSet.Auto, ExactSpelling = true, CallingConvention = CallingConvention.Winapi)]
public static extern int rf_beep(int icdev, int version);
//中止对该卡操作
[DllImport("mwhrf_bj.dll", EntryPoint = "rf_halt")]
public static extern int rf_halt(Int16 icdev);
//寻卡请求
[DllImport("mwhrf_bj.dll", EntryPoint = "rf_request" , SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
public static extern Int16 rf_request(int icdev,string IDLE, Int16* state);
//寻卡
[DllImport("mwhrf_bj.dll", EntryPoint = "rf_card")]
public static extern Int16 rf_card(int icdev, int mode,ref int Snr);
//卡防冲突,返回卡的序列号
[DllImport("mwhrf_bj.dll", EntryPoint = "rf_anticoll", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
public static extern int rf_anticoll(int icdev, char _Bcnt, Int64* _Snr);
////将密码装入读写模块RAM中
[DllImport("mwhrf_bj.dll")]
public static extern short rf_load_key(int icdev, int mode, int secnr, [In] byte[] nkey); //密码装载到读写模块中
[DllImport("mwhrf_bj.dll", EntryPoint = "rf_load_key_hex")]
public static extern Int16 rf_load_key_hex(int icdev, int mode, int secnr, string keybuff);
//验证某一扇区密码
[DllImport("mwhrf_bj.dll")]
public static extern short rf_authentication(int icdev, int _Mode, int _SecNr);
//验证某一扇区密码 2
[DllImport("mwhrf_bj.dll", EntryPoint = "rf_authentication_2")]
public static extern int rf_authentication_2(int icdev, int _Mode, int KeyNr, int Adr);
//向卡中写入数据
[DllImport("mwhrf_bj.dll", EntryPoint = "rf_write")]
public static extern int rf_write(int icdev, int _Adr, char[] _Data);
[DllImport("mwhrf_bj.dll")]
public static extern short rf_write(int icdev, int adr, [In] string sdata); //向卡中写入数据
//读取数据
[DllImport("mwhrf_bj.dll")]
public static extern short rf_read(int icdev, int adr, [MarshalAs(UnmanagedType.LPStr)] StringBuilder sdata); //从卡中读数据
byte[] tk = new byte[6] { 255, 255, 255, 255, 255, 255 };
fixed (byte* array = tk)
if ((IC.rf_load_key(icdev, '0', '1', array)) != 0)
{
MessageBox.Show("Load key error!!");
}