Ejemplo n.º 1
0
        private void InitialStart()
        {
            // Stop Windows Biometric Service to apply changes
            RestartService("WbioSrvc", 5000, ServiceMode.Stop);

            var databases = WinBio.EnumDatabases(WinBioBiometricType.Fingerprint);

            Console.WriteLine("Found {0} databases", databases.Length);
            for (var i = 0; i < databases.Length; i++)
            {
                Console.WriteLine("DatabaseId {0}: {1}", i, databases[i].DatabaseId);
            }
            if (WinBioConfiguration.DatabaseExists(DatabaseId))
            {
                Console.WriteLine("Removing database: {0}", DatabaseId);
                WinBioConfiguration.RemoveDatabase(DatabaseId);
            }

            // Start Windows Biometric Service to apply changes
            RestartService("WbioSrvc", 5000, ServiceMode.Start);

            Console.WriteLine("Creating database: {0}", DatabaseId);
            WinBioConfiguration.AddDatabase(DatabaseId, _unitId);
            Console.WriteLine("Adding sensor to the pool: {0}", _unitId);
            WinBioConfiguration.AddUnit(DatabaseId, _unitId);

            // Restart Windows Biometric Service to apply changes
            RestartService("WbioSrvc", 5000, ServiceMode.Restart);

            Log("Successfully recreated database.");

            OpenBiometricSession();
        }
        public static void EnumDatabases()
        {
            var schemaArray = WinBio.EnumDatabases(WinBioBiometricType.Fingerprint);

            Console.WriteLine("Databases found: {0}", schemaArray.Length);
            for (var i = 0; i < schemaArray.Length; i++)
            {
                Console.WriteLine("Database {0}", i);
                var id = schemaArray[i].DatabaseId;
                Console.WriteLine("Id: {0}", id);
            }
        }
Ejemplo n.º 3
0
 public static void Main()
 {
     try
     {
         var units = WinBio.EnumBiometricUnits(WinBioBiometricType.Fingerprint);
         Console.WriteLine("Found {0} units", units.Length);
         if (units.Length == 0)
         {
             return;
         }
         var unit   = units[0];
         var unitId = unit.UnitId;
         Console.WriteLine("Using unit id: {0}", unitId);
         Console.WriteLine("Device instance id: {0}", unit.DeviceInstanceId);
         var databases = WinBio.EnumDatabases(WinBioBiometricType.Fingerprint);
         Console.WriteLine("Found {0} databases", databases.Length);
         for (var i = 0; i < databases.Length; i++)
         {
             Console.WriteLine("DatabaseId {0}: {1}", i, databases[i].DatabaseId);
         }
         if (WinBioConfiguration.DatabaseExists(DatabaseId))
         {
             Console.WriteLine("Removing database: {0}", DatabaseId);
             WinBioConfiguration.RemoveDatabase(DatabaseId);
         }
         Console.WriteLine("Creating database: {0}", DatabaseId);
         WinBioConfiguration.AddDatabase(DatabaseId, unitId);
         Console.WriteLine("Adding sensor to the pool: {0}", unitId);
         WinBioConfiguration.AddUnit(DatabaseId, unitId);
         Console.WriteLine("Opening biometric session");
         var session = WinBio.OpenSession(WinBioBiometricType.Fingerprint, WinBioPoolType.Private, WinBioSessionFlag.Basic, new[] { unitId }, DatabaseId);
         try
         {
             Console.WriteLine("Type sub type and press enter:");
             WinBioBiometricSubType subType;
             if (!Enum.TryParse(Console.ReadLine(), true, out subType))
             {
                 Console.WriteLine("Invalid sub type");
                 return;
             }
             var identity = AddEnrollment(session, unitId, subType);
             Console.WriteLine("Identity: {0}", identity);
             Console.WriteLine();
             var enrollments = WinBio.EnumEnrollments(session, unitId, identity);
             Console.WriteLine("Found {0} enrollments for that identity:", enrollments.Length);
             foreach (var enrollment in enrollments)
             {
                 Console.WriteLine(enrollment);
             }
             Console.WriteLine();
             Console.WriteLine("Verify identity with any finger:");
             WinBioRejectDetail rejectDetail;
             WinBio.Verify(session, identity, WinBioBiometricSubType.Any, out unitId, out rejectDetail);
             Console.WriteLine("Success");
         }
         finally
         {
             Console.WriteLine("Closing biometric session");
             WinBio.CloseSession(session);
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine("Exception: " + ex.GetType().Name);
         Console.WriteLine(ex.Message);
         Console.WriteLine(ex.StackTrace);
     }
 }