身份证阅读器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) ;

}

}

相关推荐
----云烟----8 小时前
QT中QString类的各种使用
开发语言·qt
「QT(C++)开发工程师」14 小时前
【qt版本概述】
开发语言·qt
一路冰雨18 小时前
Qt打开文件对话框选择文件之后弹出两次
开发语言·qt
老赵的博客19 小时前
QT 自定义界面布局要诀
开发语言·qt
码码哈哈0.019 小时前
VSCode 2022 离线安装插件QT VSTOOl报错此扩展不能安装在任何当前安装的产品上。
ide·vscode·qt
feiyangqingyun1 天前
Qt/C++离线地图的加载和交互/可以离线使用/百度和天地图离线/支持手机上运行
c++·qt·qt天地图·qt离线地图·qt地图导航
gz94562 天前
windows下,用CMake编译qt项目,出现错误By not providing “FindQt5.cmake“...
开发语言·qt
「QT(C++)开发工程师」2 天前
Ubuntu 26.04 LTS 大升级:Qt 6 成为未来新引擎
qt
兆。2 天前
python实战案例----使用 PyQt5 构建简单的 HTTP 接口测试工具
爬虫·python·qt
喝哈喝哈2 天前
pycharm中配置pyqt5
python·qt·pycharm