• 大小: 99KB
    文件类型: .rar
    金币: 2
    下载: 0 次
    发布日期: 2024-01-06
  • 语言: C/C++
  • 标签: 华大HD900  C#  DEMO  HD-900  

资源简介

c#调用c++ dll 华大HD900身份证阅读器操作类, 内含代码示例及相关需引用的dll........

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;

namespace ATMS
{


//-----------------调用方法---------------------------

    [HandleProcessCorruptedStateExceptions]
        [SecurityCritical]
        private void readCert()
        {
            yes = true;
            do
            {
                Application.DoEvents(); 
                int port = 1001;
                //初始化设备
                port = HdCardDll.HD_InitComm(port);
                if (port < 0)
                {
                    // MessageBox.Show(“没打开“ + port);
                    HdCardDll.HD_CloseComm();
                }
                port = HdCardDll.HD_Authenticate(1);
                //选卡鉴权  
                if (port != 0)
                {
                    HdCardDll.HD_CloseComm();
                }
                else
                {
//单独获取模式
                    long b = HdCardDll.HD_ReadCard(); 
                    try
                    {
                        string name = HdCardDll.GetName();//获取姓名
                        string certno = HdCardDll.GetCertNo();//获取身份证号
MessageBox.Show(name);
                        MessageBox.Show(certno); 
                        yes = false;
                        HdCardDll.HD_CloseComm();
                        break;
                    }
                    catch (AccessViolationException ex)
                    {
                        HdCardDll.HD_CloseComm();
                    }
                }
                Application.DoEvents();

            } while (yes);
           
        }

    //一次获取全部信息
    StringBuilder pBmpData = new StringBuilder();
            StringBuilder pName = new StringBuilder();
            StringBuilder pSex = new StringBuilder();
            StringBuilder pNation = new StringBuilder();
            StringBuilder pBirth = new StringBuilder();
            StringBuilder pAddress = new StringBuilder();
            StringBuilder pCertNo = new StringBuilder();
            StringBuilder pDepartment = new StringBuilder();
            StringBuilder pEffectData = new StringBuilder();
            StringBuilder pExpire = new StringBuilder();
         
         pBmpData.Append(“d:\\a.bmp“);
 HdCardDll.HD_InitComm(1001);
 HdCardDll.HD_Authenticate(1);
             int c = HdCardDll.HD_Read_baseMsg(pBmpData  pName  pSex  pNation  pBirth  pAddress  pCertNo  pDepartment  pEffectData  pExpire);
             HdCardDll.HD_CloseComm();
             MessageBox.Show(pName.toString());  
//------------------------------------------------------
     
    public class HdCardDll
    {
        /// 
        ///  根据指定端口初始化设备通讯。
        /// 

        /// 整数,表示端口号; 1-16,表示串口;1001,表示USB。
        /// 1 成功 其他  失败(具体含义参见返回码表)
        [DllImport(“HDstd

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件      28672  2019-02-15 17:26  华大HD900\BmpToJpg.dll

     文件       7299  2019-02-16 17:12  华大HD900\HdCardDll.cs

     文件      49152  2019-02-15 17:26  华大HD900\HDstdapi.dll

     文件      77824  2019-02-15 17:26  华大HD900\sdtapi.dll

     文件     122880  2019-02-15 17:26  华大HD900\UnPack.dll

     目录          0  2019-02-16 16:22  华大HD900

----------- ---------  ---------- -----  ----

               285827                    6


评论

共有 条评论