0% found this document useful (0 votes)
2 views

BiometricDevice_CSharp

This document is a C# program that demonstrates how to initialize, capture, and close a fingerprint scanning device using the Nitgen SDK. It includes methods for initializing the device, capturing fingerprint data, and handling errors during these processes. The program outputs messages to the console to indicate the status of each operation.

Uploaded by

Narsimhan Iyer
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

BiometricDevice_CSharp

This document is a C# program that demonstrates how to initialize, capture, and close a fingerprint scanning device using the Nitgen SDK. It includes methods for initializing the device, capturing fingerprint data, and handling errors during these processes. The program outputs messages to the console to indicate the status of each operation.

Uploaded by

Narsimhan Iyer
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

using System;

using System.Runtime.InteropServices;
using System.Threading;
using Nitgen.SDK;

namespace NitgenFingerprintExample
{
class Program
{
// Define the necessary device constants
const int DeviceIndex = 0; // Usually, 0 is the default device if only one
is connected

// Initialize the device


static INFingerScan fingerScan = null;

static void Main(string[] args)


{
// Initialize the SDK and connect to the device
InitDevice();

// Capture fingerprint
CaptureFingerprint();

// Close the device


CloseDevice();
}

// Method to initialize the fingerprint device


static void InitDevice()
{
try
{
// Initialize the Fingerprint device (using the SDK method)
fingerScan = new INFingerScan();
fingerScan.Init();
Console.WriteLine("Device initialized successfully.");
}
catch (Exception ex)
{
Console.WriteLine("Error initializing device: " + ex.Message);
}
}

// Method to capture fingerprint from the device


static void CaptureFingerprint()
{
try
{
Console.WriteLine("Please place your finger on the scanner...");

// Start the fingerprint scanning process


byte[] fingerprintData = new byte[1024]; // Array to store
fingerprint data

// Capture fingerprint data


int result = fingerScan.Capture(fingerprintData);

if (result == 0) // 0 indicates success, check the SDK


documentation for error codes
{
Console.WriteLine("Fingerprint captured successfully.");
// Here you can process the fingerprint data (e.g., store it in
the database)
}
else
{
Console.WriteLine("Failed to capture fingerprint. Error code: "
+ result);
}
}
catch (Exception ex)
{
Console.WriteLine("Error capturing fingerprint: " + ex.Message);
}
}

// Method to close the device connection


static void CloseDevice()
{
try
{
if (fingerScan != null)
{
fingerScan.Close();
Console.WriteLine("Device closed successfully.");
}
}
catch (Exception ex)
{
Console.WriteLine("Error closing device: " + ex.Message);
}
}
}
}

You might also like