Qt动态调用读取效果
导入读卡相关函数
cpp
{
ui->setupUi(this);
//动态调用方法 donsee32.dll
m_hDLL = ::LoadLibrary(L"./donsee32.dll");
if (m_hDLL == nullptr)
ui->textEdit->append("加载动态库失败,请检查动态库路径");
else
ui->textEdit->append("加载动态库成功");
fpDonsee_Open = (DONSEE_HID_OPEN_FUNC)GetProcAddress(m_hDLL,"Donsee_Open");
fpDonsee_Close = (DONSEE_HID_CLOSE_FUNC)GetProcAddress(m_hDLL,"Donsee_Close");
fpDonsee_Beep = (DONSEE_HID_BEEP_FUNC)GetProcAddress(m_hDLL,"Donsee_Beep");
fpDonsee_Version = (DONSEE_HID_VERSION_FUNC)GetProcAddress(m_hDLL,"Donsee_Version");
fpDonsee_ReadIDCard = (DONSEE_HID_ID_READ_INFO__FUNC)GetProcAddress(m_hDLL,"Donsee_ReadIDCard");
fpDonsee_ReadIDCardUid = (DONSEE_HID_ID_READ_UID__FUNC)GetProcAddress(m_hDLL,"Donsee_ReadIDCardUid");
fpDonsee_ReadSAMID = (DONSEE_HID_ID_READ_SAMID__FUNC)GetProcAddress(m_hDLL,"Donsee_ReadSAMID");
fpDonsee_ReadSSCard = (DONSEE_HID_READ_SS_FUNC)GetProcAddress(m_hDLL,"Donsee_ReadSSCard");
fpDonsee_GetBankCardNo = (DONSEE_HID_GET_BANK_CARD_FUNC)GetProcAddress(m_hDLL,"Donsee_GetBankCardNo");
fpDonsee_ICSelect = (DONSEE_HID_IC_SELECT_FUNC)GetProcAddress(m_hDLL,"Donsee_ICSelect");
fpDonsee_ICRequest = (DONSEE_HID_IC_REQUEST_FUNC)GetProcAddress(m_hDLL,"Donsee_ICRequest");
fpDonsee_ICAnticoll = (DONSEE_HID_IC_ANTICOLL_FUNC)GetProcAddress(m_hDLL,"Donsee_ICAnticoll");
fpDonsee_SetTypeA = (DONSEE_HID_SET_TYPEA__FUNC)GetProcAddress(m_hDLL,"Donsee_SetTypeA");
fpDonsee_PowerOnTypeA = (DONSEE_HID_POWER_TYPEA__FUNC)GetProcAddress(m_hDLL,"Donsee_PowerOnTypeA");
if ( 0
|| (fpDonsee_Open == NULL)
|| (fpDonsee_Close == NULL)
|| (fpDonsee_Beep == NULL)
|| (fpDonsee_Version == NULL)
|| (fpDonsee_ReadIDCard == NULL)
|| (fpDonsee_ReadIDCardUid == NULL)
|| (fpDonsee_ReadSAMID == NULL)
|| (fpDonsee_ReadSSCard == NULL)
|| (fpDonsee_GetBankCardNo == NULL)
|| (fpDonsee_ICSelect == NULL)
|| (fpDonsee_ICRequest == NULL)
|| (fpDonsee_ICAnticoll == NULL)
|| (fpDonsee_SetTypeA == NULL)
|| (fpDonsee_PowerOnTypeA == NULL)
)
{
ui->textEdit->append("定位 donsee32.dll 中的所需函数失败!");
FreeLibrary(m_hDLL);
}
m_isOpen = false ;
}
读身份证接口
cpp
void MainWindow::on_btnIDCard_clicked()
{
if(m_isOpen == false)
{
ui->textEdit->append("读卡器端口未打开") ;
return ;
}
IDINFO idInfo;
char t_arrMsg[256];
char t_szMsg[256] = "" ;
// nType [in]:设置身份证读卡类型:0,文本信息;1,文本+照片;2,文本+照片+指纹
int nType = 1;
memset(&idInfo, 0, sizeof(IDINFO));
// char t_szPath[256] = "/tmp/IDPhoto.bmp";
char t_szPath[256] = "./IDPhoto.bmp";
// char t_szPath[256] = "";
// char t_szPath[256] = NULL;
long t_nRe = fpDonsee_ReadIDCard(nType, t_szPath, &idInfo, t_arrMsg);
if (t_nRe != 0)
{
printf("读身份证失败\n");
ui->textEdit->append("读身份证失败") ;
return ;
}
else
{
QString t_strTemp1 , t_strTemp2 ;
printf("读身份证成功\n");
ui->textEdit->append("读身份证成功") ;
t_strTemp1 = "中文姓名:" ;
t_strTemp2 = GBKtoUtf8(idInfo.name) ;
ui->textEdit->append(t_strTemp1 + t_strTemp2) ;
printf(("英文姓名:%s\n"), idInfo.ENfullname);
sprintf(t_szMsg,("英文姓名:%s"), idInfo.ENfullname) ;
ui->textEdit->append(t_szMsg) ;
t_strTemp1 = "性 别:" ;
t_strTemp2 = GBKtoUtf8(idInfo.sex) ;
ui->textEdit->append(t_strTemp1 + t_strTemp2) ;
t_strTemp1 = "民 族:" ;
t_strTemp2 = GBKtoUtf8(idInfo.people) ;
ui->textEdit->append(t_strTemp1 + t_strTemp2) ;
printf(("出身日期:%s\n"), idInfo.birthday);
sprintf(t_szMsg,("出身日期:%s"), idInfo.birthday) ;
ui->textEdit->append(t_szMsg) ;
t_strTemp1 = "住 址:" ;
t_strTemp2 = GBKtoUtf8(idInfo.address) ;
ui->textEdit->append(t_strTemp1 + t_strTemp2) ;
printf(("身份证号:%s\n"), idInfo.number);
sprintf(t_szMsg,("身份证号:%s"), idInfo.number) ;
ui->textEdit->append(t_szMsg) ;
t_strTemp1 = "签发机关:" ;
t_strTemp2 = GBKtoUtf8(idInfo.organs) ;
ui->textEdit->append(t_strTemp1 + t_strTemp2) ;
printf(("有效期开始:%s\n"), idInfo.signdate);
sprintf(t_szMsg,("有效期开始:%s"), idInfo.signdate) ;
ui->textEdit->append(t_szMsg) ;
printf(("有效期结束:%s\n"), idInfo.validterm);
sprintf(t_szMsg,("有效期结束:%s"), idInfo.validterm) ;
ui->textEdit->append(t_szMsg) ;
printf(("证件类别:%s\n"), idInfo.certType);
sprintf(t_szMsg,("证件类别:%s"), idInfo.certType) ;
ui->textEdit->append(t_szMsg) ;
printf(("证件版本:%s\n"), idInfo.certVersion);
sprintf(t_szMsg,("证件版本:%s"), idInfo.certVersion) ;
ui->textEdit->append(t_szMsg) ;
printf(("通行证号:%s\n"), idInfo.passNu);
sprintf(t_szMsg,("通行证号:%s"), idInfo.passNu) ;
ui->textEdit->append(t_szMsg) ;
printf(("签发数次:%s\n"), idInfo.signCount);
sprintf(t_szMsg,("签发数次:%s"), idInfo.signCount) ;
ui->textEdit->append(t_szMsg) ;
}
}
读社保卡接口
void MainWindow::on_btnSSCard_clicked()
{
if(m_isOpen == false)
{
ui->textEdit->append("读卡器端口未打开") ;
return ;
}
char t_szMsg[256] = "" ;
SSCard_IDINFO cardInfo;
memset(&cardInfo, 0, sizeof(cardInfo));
char pszError[256] = "" ;
long t_nRead = fpDonsee_ReadSSCard(0x11, &cardInfo, pszError);
if (t_nRead != 0)
{
printf("读社保卡失败,MSG:%s\n", pszError);
sprintf(t_szMsg,"读社保卡失败,MSG:%s", pszError) ;
ui->textEdit->append(t_szMsg) ;
return ;
}
else
{
QString t_strTemp1 , t_strTemp2 ;
printf("读社保卡成功\n");
ui->textEdit->append("读社保卡成功") ;
t_strTemp1 = "姓名:" ;
t_strTemp2 = GBKtoUtf8(cardInfo.name) ;
ui->textEdit->append(t_strTemp1 + t_strTemp2) ;
t_strTemp1 = "性别:" ;
t_strTemp2 = GBKtoUtf8(cardInfo.sex) ;
ui->textEdit->append(t_strTemp1 + t_strTemp2) ;
t_strTemp1 = "民族:" ;
t_strTemp2 = GBKtoUtf8(cardInfo.nation) ;
ui->textEdit->append(t_strTemp1 + t_strTemp2) ;
printf("出生日期:%s\n", cardInfo.birthday);
sprintf(t_szMsg,"出生日期:%s", cardInfo.birthday) ;
ui->textEdit->append(t_szMsg) ;
printf("发证日期:%s\n", cardInfo.signdate);
sprintf(t_szMsg,"发证日期:%s", cardInfo.signdate) ;
ui->textEdit->append(t_szMsg) ;
printf("有效日期:%s\n", cardInfo.validterm);
sprintf(t_szMsg,"有效日期:%s", cardInfo.validterm) ;
ui->textEdit->append(t_szMsg) ;
printf("卡号:%s\n", cardInfo.cardnumber);
sprintf(t_szMsg,"卡号:%s", cardInfo.cardnumber) ;
ui->textEdit->append(t_szMsg) ;
printf("社会保障号码(身份证号):%s\n", cardInfo.idnumber);
sprintf(t_szMsg,"社会保障号码(身份证号):%s", cardInfo.idnumber) ;
ui->textEdit->append(t_szMsg) ;
printf("城市代码:%s\n", cardInfo.city);
sprintf(t_szMsg,"城市代码:%s", cardInfo.city) ;
ui->textEdit->append(t_szMsg) ;
printf("社保卡版本:%s\n", cardInfo.cardveVrsion);
sprintf(t_szMsg,"社保卡版本:%s", cardInfo.cardveVrsion ) ;
ui->textEdit->append(t_szMsg) ;
}
}