身份证阅读器Qt动态调用方法donsee32.dll实现读取身份证信息、社保卡信息、IC卡、银行卡等信息

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) ;

}

}

相关推荐
徒步僧9 小时前
ThingsBoard规则链节点:RPC Call Reply节点详解
qt·microsoft·rpc
可峰科技10 小时前
斗破QT编程入门系列之一:认识Qt:初步使用(四星斗师)
开发语言·qt
我喜欢就喜欢10 小时前
基于qt vs下的视频播放
开发语言·qt·音视频
CP-DD11 小时前
Qt的架构设计
qt
阿_旭11 小时前
基于YOLO11/v10/v8/v5深度学习的维修工具检测识别系统设计与实现【python源码+Pyqt5界面+数据集+训练代码】
人工智能·python·深度学习·qt·ai
Bruce小鬼16 小时前
QT创建按钮篇
开发语言·qt
martian66517 小时前
QT开发:掌握现代UI动画技术:深入解析QML和Qt Quick中的动画效果
开发语言·c++·qt·ui
墨染新瑞19 小时前
两个有趣的小东西(qt和类型转换)
开发语言·网络·qt
Bruce小鬼20 小时前
解决MAC安装QT启动项目不显示窗口问题
开发语言·qt·macos
云雨歇1 天前
Qt学习笔记(三)网络编程
笔记·qt·学习