C#Winform应用
怎么用winform窗体建卡,就是把数据库的数据读入卡中,然后通过读卡器读取数据,读卡和写卡。。。急需知道这个东西。 --------------------编程问答-------------------- 这个需要你这个 读(写、发)卡器 硬件供应商提代接口程序,通常就是一个 DLL 文件,
然后还有说明文件,有些还有例子程序。
不同牌子的发卡器 是不通用的。
--------------------编程问答-------------------- 是不是 做考勤的那种 IC 卡呀,我就是做这种的。
--------------------编程问答-------------------- serialPort操作
相关接口
http://topic.csdn.net/u/20080318/10/f43d46e5-50ee-4e6e-90b0-509000159a72.html --------------------编程问答-------------------- 我做过读卡写卡这类,是要硬件厂家给你提供dll接口,然后你根据文档调用方法。。。 --------------------编程问答-------------------- 直接调用硬件商给你的api方法就可以了,过程基本就是读数据库---------->写卡 --------------------编程问答-------------------- 我曾经做的,但是不同的卡用的方法也不一样。。所以只做参考
//c++函数强制声明
[DllImport("mi.dll", EntryPoint = "API_OpenComm")]
public static extern IntPtr API_OpenComm(int nCom, int nBaudrate);
[DllImport("mi.dll", EntryPoint = "API_CloseComm")]
public static extern bool API_CloseComm(IntPtr commHandle);
[DllImport("mi.dll", EntryPoint = "API_ControlBuzzer")]
public static extern int API_ControlBuzzer(IntPtr commHandle, int DeviceAddress, byte freq, byte duration, ref byte buffer);
[DllImport("mi.dll", EntryPoint = "API_MF_Read")]
public static extern int API_MF_Read(IntPtr commHandle, int DeviceAddress, byte mode, byte blk_add, byte num_blk, ref byte snr, ref byte buffer);
[DllImport("mi.dll", EntryPoint = "API_MF_Write")]
public static extern int API_MF_Write(IntPtr commHandle, int DeviceAddress, byte mode, byte blk_add, byte num_blk, ref byte key, ref byte buffer);
//连接读卡
Program.Port = API_OpenComm(4, 9600);
if (Program.Port.ToInt32() == 0)
{
MessageBox.Show("读卡器连接失败!");
return;
}
byte pBuf = new byte();
Program.G_start = API_ControlBuzzer(Program.Port, 0, 3, 1, ref pBuf);
if (Program.G_start == 0)
{
//MessageBox.Show("读卡器连接成功!");
}
//写卡信息方法
hex1 = BitConverter.GetBytes(Convert.ToInt64(Id.ToString()));
for (int i = 0; i < 8; i++)
{
hex2[i] = hex1[i];
}
int idata = API_MF_Write(Program.Port, 0, 0, 10, 1, ref hex[0], ref hex2[0]);
//无卡接触时
if (idata != 0)
{
MessageBoxEx.Show("写卡有误,请确认卡放在指定位置!");
API_CloseComm(Program.Port);
return;
}
以上只是写卡的一些关键步骤,读卡其实原理也一样。 --------------------编程问答-------------------- Lz结贴率真够低的。。 --------------------编程问答-------------------- 看到如此彪悍的结贴率,让人有打酱油的冲动。。。 --------------------编程问答-------------------- 我在网上找了个免费的VPS,我试用过了很好,有三出口的平台,还有专业的NOC团队,有兴趣的可以加他们客服QQ:835212833 --------------------编程问答-------------------- --------------------编程问答-------------------- 我这个月也开始搞一卡通卡发了,我没搞过这行,文盲一个,要努力学习了,楼主有兴趣的话,加QQ:289130134
共同学习!
补充:.NET技术 , .NET Framework