示例#1
0
 /// <summary>
 /// 结束资源
 /// </summary>
 public void Dispose()
 {
     try
     {
         DLLHelper.CH9326CloseDevice(hand);
     }
     catch (Exception ex)
     {
         Logger.WriteLog("结束身份证读卡器句柄错误:" + ex.Message);
     }
 }
示例#2
0
        public static IntPtr GetCFBoolean(bool flag)
        {
            string strEnumName = flag ? "kCFBooleanTrue" : "kCFBooleanFalse";

            IntPtr modulePtr = GetModuleHandle("CoreFoundation.dll");

            if (modulePtr == IntPtr.Zero)
            {
                string appleApplicationSupportFolder = DLLHelper.GetAppleApplicationSupportFolder();
                if (!string.IsNullOrWhiteSpace(appleApplicationSupportFolder))
                {
                    modulePtr = LoadLibrary(Path.Combine(appleApplicationSupportFolder, "CoreFoundation.dll"));
                }
            }
            IntPtr zero = IntPtr.Zero;

            if (modulePtr != IntPtr.Zero)
            {
                zero = GetProcAddress(modulePtr, strEnumName);
            }
            return(Marshal.ReadIntPtr(zero, 0));
        }
示例#3
0
        /// <summary>
        /// USBHID协议驱动打开
        /// </summary>
        /// <returns></returns>
        public int USBHIDOpen()
        {
            string vid = "1A86"; string pid = "E010";

            try
            {
                ushort VID = Convert.ToUInt16(vid, 16); ushort PID = Convert.ToUInt16(pid, 16);
                hand = DLLHelper.CH9326OpenDevices(VID, PID);
                if (hand.unused > 0)
                {
                    DLLHelper.CH9326CloseDevice(hand);
                    return(1);
                }
                else
                {
                    return(0);
                }
            }
            catch (Exception ex)
            {
                Logger.WriteLog(ex.Message);
                return(0);
            }
        }
示例#4
0
 /// <summary>
 /// 打开设备读取数据
 /// </summary>
 public void Start()
 {
     System.Threading.Tasks.Task.Factory.StartNew(() =>
     {
         string vid = "1A86";
         string pid = "E010";
         string ver = "3400";
         ushort VID = Convert.ToUInt16(vid, 16);
         ushort PID = Convert.ToUInt16(pid, 16);
         ushort VER = Convert.ToUInt16(ver, 16);
         hand       = DLLHelper.CH9326OpenDevices(VID, PID);
         while (true)
         {
             try
             {
                 //设置身份
                 bool CodeBool = true;
                 System.Threading.Thread.Sleep(300);
                 int SetUpAntenna = DLLHelper.SetUpAntenna();//设置天线
                 if (SetUpAntenna == 1)
                 {
                     int Colese         = DLLHelper.OPenAntenna();
                     int SetUpAgreement = DLLHelper.SetUpAgreement();
                     if (SetUpAgreement == 1)
                     {
                         int FindCard = DLLHelper.FindCard();//找卡
                         if (FindCard == 1)
                         {
                             int SelectCard = DLLHelper.SelectCard();//选卡
                             if (SelectCard == 1)
                             {
                                 CodeBool = false;
                                 FillData();
                                 Console.Beep(2500, 300);
                             }
                         }
                     }
                     if (CodeBool)
                     {
                         int IC = DLLHelper.SetUpICAgreement();// 设置ic协议
                         if (IC == 1)
                         {
                             byte[] uid   = new byte[8];
                             int SetICUID = DLLHelper.SetICUID(uid);// 查询出IC卡上的信息
                             if (SetICUID == 1)
                             {
                                 OnCvrIcReceived(BitConverter.ToString(uid).Replace("-", ""));
                                 Console.Beep(2500, 300);
                             }
                         }
                     }
                     DLLHelper.CH9326ClearThreadData(hand);
                 }
             }
             catch (Exception ex)
             {
                 Logger.WriteLog("读卡出错:" + ex.Message);
             }
         } //while循环
     });
 }