private void btnInit_Click(object sender, EventArgs e) { try { iPort = idCard.InitDevice(); this.txtInit.Text = iPort.ToString(); //IDCardAPI.SDT_SetMaxRFByte(iPort, 36, 1); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public string Read() { try { int i = idCard.InitDevice(); if (i == 1001) { try { EDZ obj = idCard.ReadICCard(i); string str = JsonConvert.SerializeObject(obj); MessageBox.Show("读取成功" + str); return(str); } catch { MessageBox.Show("未放卡或卡未放好!请重新放卡!"); return(""); } } MessageBox.Show("设备初始化未成功!请检查设备连接状态!"); return(""); } catch (Exception e) { MessageBox.Show("设备初始化未成功!请检查设备连接状态!"); return(""); } }
//身份证读取 private void button2_Click(object sender, EventArgs e) { //this.iCardForm.Show(); //this.iCardForm.Refresh(); int i = idCard.InitDevice(); Thread.Sleep(5000); string str = idCard.ReadICCard(i).ToString(); MessageBox.Show(str); }