/// <summary> /// 关闭端口 /// </summary> public bool ClosePort() { try { CVR_IDENTITY_DLL.CVR_CloseComm(); } catch (Exception ex) { throw new Exception(ex.ToString()); } return(true); }
/// <summary> /// 得到身份证信息 /// </summary> /// <returns>身份证信息实体</returns> public IDCardInfo FillData() { try { IDCardInfo cardInfo = new IDCardInfo(); // cardInfo.ImagePath = Application.StartupPath + "\\zp.bmp"; byte[] name = new byte[30]; int length = 30; CVR_IDENTITY_DLL.GetPeopleName(ref name[0], ref length); //MessageBox.Show(); byte[] number = new byte[30]; length = 36; CVR_IDENTITY_DLL.GetPeopleIDCode(ref number[0], ref length); byte[] people = new byte[30]; length = 3; CVR_IDENTITY_DLL.GetPeopleNation(ref people[0], ref length); byte[] validtermOfStart = new byte[30]; length = 16; CVR_IDENTITY_DLL.GetStartDate(ref validtermOfStart[0], ref length); byte[] birthday = new byte[30]; length = 16; CVR_IDENTITY_DLL.GetPeopleBirthday(ref birthday[0], ref length); byte[] address = new byte[30]; length = 70; CVR_IDENTITY_DLL.GetPeopleAddress(ref address[0], ref length); byte[] validtermOfEnd = new byte[30]; length = 16; CVR_IDENTITY_DLL.GetEndDate(ref validtermOfEnd[0], ref length); byte[] signdate = new byte[30]; length = 30; CVR_IDENTITY_DLL.GetDepartment(ref signdate[0], ref length); byte[] sex = new byte[30]; length = 3; CVR_IDENTITY_DLL.GetPeopleSex(ref sex[0], ref length); cardInfo.Address = System.Text.Encoding.GetEncoding("GB2312").GetString(address).Replace("\0", "").Trim(); cardInfo.Sex = System.Text.Encoding.GetEncoding("GB2312").GetString(sex).Replace("\0", "").Trim(); cardInfo.Birthday = System.Text.Encoding.GetEncoding("GB2312").GetString(birthday).Replace("\0", "").Trim(); cardInfo.Signdate = System.Text.Encoding.GetEncoding("GB2312").GetString(signdate).Replace("\0", "").Trim(); cardInfo.Number = System.Text.Encoding.GetEncoding("GB2312").GetString(number).Replace("\0", "").Trim(); cardInfo.Name = System.Text.Encoding.GetEncoding("GB2312").GetString(name).Replace("\0", "").Trim(); cardInfo.People = System.Text.Encoding.GetEncoding("GB2312").GetString(people).Replace("\0", "").Trim(); cardInfo.ValidDate = System.Text.Encoding.GetEncoding("GB2312").GetString(validtermOfStart).Replace("\0", "").Trim() + "-" + System.Text.Encoding.GetEncoding("GB2312").GetString(validtermOfEnd).Replace("\0", "").Trim(); return(cardInfo); } catch (Exception ex) { throw new Exception(ex.ToString()); } }
/// <summary> /// 读取身份证信息 /// </summary> /// <returns>身份证信息实体</returns> public IDCardInfo ReadCard() { try { int authenticate = CVR_IDENTITY_DLL.CVR_Authenticate(); if (authenticate == 1) { int readContent = CVR_IDENTITY_DLL.CVR_Read_Content(2); if (readContent == 1) { return(FillData()); } } return(null); } catch (Exception ex) { throw new Exception(ex.ToString()); } }
/// <summary> /// 打开身份证读卡器端口 /// </summary> /// <returns>true成功 false失败</returns> public bool OpenPort() { try { int iPort = 1001; iRetUSB = CVR_IDENTITY_DLL.CVR_InitComm(iPort); if (iRetUSB == 1) { return(true); } else { return(false); } } catch (Exception ex) { throw new Exception(ex.Message); } }