Example #1
0
 private void DoCapture()
 {
     while (!g_bIsTimeToDie)
     {
         int ret = ZKFPCap.sensorCapture(g_Handle, g_FPBuffer, g_FPBufferSize);
         if (ret > 0)
         {
             SendMessage(g_FormHandle, MESSAGE_FP_RECEIVED, IntPtr.Zero, IntPtr.Zero);
         }
     }
 }
Example #2
0
        private void FreeSensor()
        {
            g_bIsTimeToDie = true;
            Thread.Sleep(1000);
            ZKFPCap.sensorClose(g_Handle);

            // Disable log
            byte[] paramValue = new byte[4];
            paramValue[0] = 0;
            ZKFPCap.sensorSetParameterEx(g_Handle, 1100, paramValue, 4);

            ZKFPCap.sensorFree();
        }
Example #3
0
        private void btnConnect_Click(object sender, EventArgs e)
        {
            if (!gConnected)
            {
                int    ret        = 0;
                byte[] paramValue = new byte[64];

                // Enable log
                Array.Clear(paramValue, 0, paramValue.Length);
                paramValue[0] = 1;
                ZKFPCap.sensorSetParameterEx(g_Handle, 1100, paramValue, 4);

                ret = ZKFPCap.sensorInit();
                if (ret != 0)
                {
                    MessageBox.Show("Init Failed, ret=" + ret.ToString());
                    return;
                }
                g_Handle = ZKFPCap.sensorOpen(0);

                Array.Clear(paramValue, 0, paramValue.Length);
                ZKFPCap.sensorGetVersion(paramValue, paramValue.Length);

                ret = paramValue.Length;
                Array.Clear(paramValue, 0, paramValue.Length);
                ZKFPCap.sensorGetParameterEx(g_Handle, 1, paramValue, ref ret);
                g_nWidth = BitConverter.ToInt32(paramValue, 0);

                this.picFP.Width = g_nWidth;


                ret = paramValue.Length;
                Array.Clear(paramValue, 0, paramValue.Length);
                ZKFPCap.sensorGetParameterEx(g_Handle, 2, paramValue, ref ret);
                g_nHeight = BitConverter.ToInt32(paramValue, 0);

                this.picFP.Height = g_nHeight;

                ret = paramValue.Length;
                Array.Clear(paramValue, 0, paramValue.Length);
                ZKFPCap.sensorGetParameterEx(g_Handle, 106, paramValue, ref ret);
                g_FPBufferSize = BitConverter.ToInt32(paramValue, 0);

                g_FPBuffer = new byte[g_FPBufferSize];
                Array.Clear(g_FPBuffer, 0, g_FPBuffer.Length);

                // get vid&pid
                ret = paramValue.Length;
                Array.Clear(paramValue, 0, paramValue.Length);
                ZKFPCap.sensorGetParameterEx(g_Handle, 1015, paramValue, ref ret);
                int nVid = BitConverter.ToInt16(paramValue, 0);
                int nPid = BitConverter.ToInt16(paramValue, 2);

                // Manufacturer
                ret = paramValue.Length;
                Array.Clear(paramValue, 0, paramValue.Length);
                ZKFPCap.sensorGetParameterEx(g_Handle, 1101, paramValue, ref ret);
                string manufacturer = System.Text.Encoding.ASCII.GetString(paramValue);
                // Product
                ret = paramValue.Length;
                Array.Clear(paramValue, 0, paramValue.Length);
                ZKFPCap.sensorGetParameterEx(g_Handle, 1102, paramValue, ref ret);
                string product = System.Text.Encoding.ASCII.GetString(paramValue);
                // SerialNumber
                ret = paramValue.Length;
                Array.Clear(paramValue, 0, paramValue.Length);
                ZKFPCap.sensorGetParameterEx(g_Handle, 1103, paramValue, ref ret);
                string serialNumber = System.Text.Encoding.ASCII.GetString(paramValue);

                // Fingerprint Alg
                short[] iSize = new short[24];
                iSize[0]       = (short)g_nWidth;
                iSize[1]       = (short)g_nHeight;
                iSize[20]      = (short)g_nWidth;
                iSize[21]      = (short)g_nHeight;;
                g_biokeyHandle = ZKFinger10.BIOKEY_INIT(0, iSize, null, null, 0);
                if (g_biokeyHandle == IntPtr.Zero)
                {
                    MessageBox.Show("BIOKEY_INIT failed");
                    return;
                }

                // Set allow 360 angle of Press Finger
                ZKFinger10.BIOKEY_SET_PARAMETER(g_biokeyHandle, 4, 180);

                // Set Matching threshold
                ZKFinger10.BIOKEY_MATCHINGPARAM(g_biokeyHandle, 0, ZKFinger10.THRESHOLD_MIDDLE);

                // Init RegTmps
                for (int i = 0; i < 3; i++)
                {
                    g_RegTmps[i] = new byte[2048];
                }

                Thread captureThread = new Thread(new ThreadStart(DoCapture));
                captureThread.IsBackground = true;
                captureThread.Start();
                g_bIsTimeToDie = false;

                gConnected          = true;
                btnRegister.Enabled = true;
                btnVerify.Enabled   = true;
                btnConnect.Text     = "Disconnect Sensor";

                txtPrompt.Text = "Please put your finger on the sensor";
                tssLbl1.Text   = "请把手指放在传感器上。";
            }
            else
            {
                FreeSensor();

                ZKFinger10.BIOKEY_DB_CLEAR(g_biokeyHandle);
                ZKFinger10.BIOKEY_CLOSE(g_biokeyHandle);

                gConnected          = false;
                btnRegister.Enabled = false;
                btnVerify.Enabled   = false;
                btnConnect.Text     = "Connect Sensor";
            }
        }