C # Developing ActiveX controls and fingerprint capture

Source: Internet
Author: User

Recently do a fingerprint capture and comparison of the function, because the company's entire project is the Web type, so the Fingerprint collection module to be nested in the Web page, that only with ActiveX, the following are some of the operation and effect, make a note!

Create a new user control and write the CS code as follows:

Using system;using system.collections.generic;using system.componentmodel;using system.drawing;using System.Data; Using system.text;using system.runtime.interopservices;using system.windows.forms;using System.IO; Using System.reflection;namespace fingertool{[Guid ("5136cba1-59b0-4a96-b2dc-64062a81f377")] public partial class Fi        ngertooluc:usercontrol,iobjectsafety {public Fingertooluc () {InitializeComponent ();        } frmmain fm = NULL;            public void Showsettingform () {if (fm = = NULL) {FM = new frmmain (); } FM.        ShowDialog (); } #region Call the JS interface [ComImport, Guid ("00000118-0000-0000-c000-000000000046"), InterfaceType (cominterfacetype.in            Terfaceisiunknown)] public interface IOleClientSite {void Saveobject ();            void GetMoniker (UINT dwassign, uint dwwhichmoniker, Object PPMK); void GetContainer (out IOlEcontainer Ppcontainer);            void Showobject ();            void Onshowwindow (bool fshow);        void Requestnewobjectlayout (); } [ComImport, Guid ("0000011b-0000-0000-c000-000000000046"), InterfaceTypeAttribute ( Cominterfacetype.interfaceisiunknown)] public interface IOleContainer {void EnumObjects ([In, Mar            Shalas (UNMANAGEDTYPE.U4)] int grfflags, [out, MarshalAs (UnmanagedType.LPArray)] object[] ppenum);  void ParseDisplayName ([In, MarshalAs (unmanagedtype.interface)] Object PBC, [In, MarshalAs (UNMANAGEDTYPE.BSTR)] String pszDisplayName, [out, MarshalAs (UnmanagedType.LPArray)] int[] Pcheaten, [out, MarshalAs (Un            Managedtype.lparray)] [object[] ppmkout);        void Lockcontainer ([In, MarshalAs (UNMANAGEDTYPE.I4)] int fLock); } #endregion #region IE Secure Interface Private Const string _iid_idispatch = "{00020400-0000-0000-c000-00000000        0046} "; Private Const STRing _iid_idispatchex = "{a6ef9860-c720-11d0-9337-00a0c90dcaa9}";        Private Const String _iid_ipersiststorage = "{0000010a-0000-0000-c000-000000000046}";        Private Const String _iid_ipersiststream = "{00000109-0000-0000-c000-000000000046}";        Private Const String _iid_ipersistpropertybag = "{37d84f60-42cb-11ce-8135-00aa004bb851}";        Private Const int interfacesafe_for_untrusted_caller = 0x00000001;        Private Const int interfacesafe_for_untrusted_data = 0x00000002;        Private Const int S_OK = 0;        Private Const int E_FAIL = unchecked ((int) 0x80004005);        Private Const int E_NOINTERFACE = unchecked ((int) 0x80004002);        private bool _fsafeforscripting = true;        private bool _fsafeforinitializing = true;            public int getinterfacesafetyoptions (ref Guid riid, ref int pdwsupportedoptions, ref int pdwenabledoptions) {            int Rslt = E_FAIL; String strguid = riid.            ToString ("B"); Pdwsupportedoptions = INTERFACEsafe_for_untrusted_caller |            Interfacesafe_for_untrusted_data;                    Switch (strguid) {case _iid_idispatch:case _iid_idispatchex:                    Rslt = S_OK;                    pdwenabledoptions = 0;                    if (_fsafeforscripting = = true) Pdwenabledoptions = Interfacesafe_for_untrusted_caller;                Break                    Case _iid_ipersiststorage:case _iid_ipersiststream:case _iid_ipersistpropertybag:                    Rslt = S_OK;                    pdwenabledoptions = 0;                    if (_fsafeforinitializing = = true) Pdwenabledoptions = Interfacesafe_for_untrusted_data;                Break                    Default:rslt = E_nointerface;            Break        } return Rslt; }


Fingerprint acquisition Key code:

private void Axzkfpengx1_onimagereceived (object sender, Axzkfpengxcontrol.izkfpengxevents_onimagereceivedevent e) {            if (!e.aimagevalid) return;            if (axzkfpengx1.isdisposed) return; try {if (picturebox1.image! = null) {PICTUREBOX1.IMAGE.DISPO SE ();//release file resource pictureBox1.Image = null;//Clear Picture} if (!                System.IO.Directory.Exists (Mvpath)) {System.IO.Directory.CreateDirectory (Mvpath); } string FilePath = Mvpath + "\ \" + Guid.NewGuid ().                ToString () + ". bmp"; Axzkfpengx1.savebitmap (FilePath);//Save new file pictureBox1.Image = System.Drawing.Bitmap.FromFile (FilePath);//display diagram                Film Picturebox1.refresh ();                if (This.txtValue.Text.Trim () = "") {setmsg ("", "Control"); }} catch (EXception ex) {MessageBox.Show (ex.            Message);         }} private void Axzkfpengx1_onfeatureinfo (object sender, Axzkfpengxcontrol.izkfpengxevents_onfeatureinfoevent e)            {String stemp = ""; if (axzkfpengx1.isregister) {stemp = "enlistment status: Also need to press:" + (axzkfpengx1.enrollindex-1).            ToString () + "secondary fingerprint";            } stemp = stemp + "fingerprint quality"; if (e.aquality! = 0) {if (e.aquality = = 1) {stemp = stemp +                "Feature point is not enough";                } else {stemp = stemp + "Other causes cannot be taken to fingerprint feature";            }} else {stemp = stemp + "qualified";        } this.lblMessage.Text = stemp; }


The Fingerprint verification section, the last saved fingerprint is the converted BASE64 string

String value_old= "";//Registered fingerprint string value_curr= "";//Current fingerprint bool IsOK = false;            BOOL Bregchange = false;            if (AXZKFPENGX1.VERFINGERFROMSTR (ref value_old, Value_curr, False, ref Bregchange))            {                IsOK = true;            }            if (AXZKFPENGX1.VERFINGERFROMSTR (ref value_old2, Value_curr, False, ref Bregchange))            {                IsOK = true;            }            if (IsOK)            {                MessageBox.Show ("OK");            }            else            {                MessageBox.Show ("NG");            }


Set COM properties for a project

Register this plugin on the page

The number of fingerprint acquisition can be customized, the default is to collect three times after the save, the device is a central control of the collector.

C # Developing ActiveX controls and fingerprint capture

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.