//读卡器介绍:https://item.taobao.com/item.htm?spm=a1z10.5-c.w4002-17663462238.23.16795b43onC5S2&id=600862990715https://item.taobao.com/item.htm?spm=a1z10.5-c.w4002-17663462238.23.16795b43onC5S2&id=600862990715
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.Runtime.InteropServices; //调用动态库一定要加入这个引用 namespace idcardreader { public partial class Form1 : Form { //------------------------------------------------------------------------------------------------------------------------------------------------------ //外部函数声明:让设备发出声响 [DllImport("OUR_IDR_x64.dll", EntryPoint = "idr_beep", CallingConvention = CallingConvention.StdCall)] static extern byte idr_beep(UInt32 xms);//xms单位为毫秒 //------------------------------------------------------------------------------------------------------------------------------------------------------ //读取设备编号,可做为软件加密狗用,也可以根据此编号在公司网站上查询保修期限 [DllImport("OUR_IDR_x64.dll", EntryPoint = "pcdgetdevicenumber", CallingConvention = CallingConvention.StdCall)] static extern byte pcdgetdevicenumber(byte[] devicenumber);//devicenumber用于返回编号 //------------------------------------------------------------------------------------------------------------------------------------------------------ //只读卡号 [DllImport("OUR_IDR_x64.dll", EntryPoint = "idr_read", CallingConvention = CallingConvention.StdCall)] public static extern byte idr_read(byte[] serial);//serial返回卡号 //------------------------------------------------------------------------------------------------------------------------------------------------------ //只读卡号,只读一次,必须拿开卡才能再读到 [DllImport("OUR_IDR_x64.dll", EntryPoint = "idr_read_once", CallingConvention = CallingConvention.StdCall)] public static extern byte idr_read_once(byte[] serial);//serial返回卡号 //------------------------------------------------------------------------------------------------------------------------------------------------------ //发送显示内容到读卡器 //[DllImport("OUR_IDR.dll", EntryPoint = "lcddispfull", CallingConvention = CallingConvention.StdCall)] //static extern byte lcddispfull(string lcdstr); //参数:说明 public Form1() { InitializeComponent(); } private void button2_Click(object sender, EventArgs e) { byte status;//存放返回值 byte[] myserial = new byte[5];//卡序列号 status = idr_read(myserial); switch (status) { case 0: idr_beep(50); MessageBox.Show("读卡成功,卡号为" + System.Convert.ToString(myserial[1] * 256 * 256 * 256 + myserial[2] * 256 * 256 + myserial[3] * 256 + myserial[4])); //MessageBox.Show("操作成功,卡号已在myserial中,卡号一般为myserial[0]卡厂商标识,myserial[1]到myserial[4]为卡号,用户可以组合为各种卡号编码。"); break; //...... case 8: MessageBox.Show("请将卡放在感应区"); break; default: MessageBox.Show("返回码(对应的说明请看例子中的注释):" + status); break; } } private void button7_Click(object sender, EventArgs e) {//嘀一声 idr_beep(50); } private void button6_Click(object sender, EventArgs e) {//读取设备编号,可做为软件加密狗用 byte[] devno = new byte[4]; if (pcdgetdevicenumber(devno) == 0) { MessageBox.Show(System.Convert.ToString(devno[0]) + "-" + System.Convert.ToString(devno[1]) + "-" + System.Convert.ToString(devno[2]) + "-" + System.Convert.ToString(devno[3])); //ShowMessage(IntToStr(devno[0]) + "-" + IntToStr(devno[1]) + "-" + IntToStr(devno[2]) + "-" + IntToStr(devno[3])); } } private void button4_Click(object sender, EventArgs e) { byte status;//存放返回值 byte[] myserial = new byte[5];//卡序列号 status = idr_read_once(myserial); switch (status) { case 0: idr_beep(50); MessageBox.Show("读卡成功,卡号为" + System.Convert.ToString(myserial[1] * 256 * 256 * 256 + myserial[2] * 256 * 256 + myserial[3] * 256 + myserial[4])); //MessageBox.Show("操作成功,卡号已在myserial中,卡号一般为myserial[0]卡厂商标识,myserial[1]到myserial[4]为卡号,用户可以组合为各种卡号编码。"); break; //...... case 8: MessageBox.Show("请将卡放在感应区"); break; default: MessageBox.Show("返回码(对应的说明请看例子中的注释):" + status); break; } } } }
最后
以上就是忧郁抽屉最近收集整理的关于C#读取RFID卡号源码的全部内容,更多相关C#读取RFID卡号源码内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复