كود :
Imports zkemkeeper
Public Class ZKTecoVerification
Private zkem As New CZKEM()
Public Sub VerifyOwnerFingerprint()
' Connect to the ZKTeco machine
Dim isConnected As Boolean = zkem.Connect_Net("192.168.0.201", 4370) ' Replace with your machine's IP and port
If isConnected Then
' Read the fingerprint template from the machine
Dim templateData As Byte() = ReadFingerprintTemplate()
If templateData IsNot Nothing Then
' Check if the fingerprint template belongs to the owner
Dim isOwnerTemplate As Boolean = VerifyOwnerTemplate(templateData)
If isOwnerTemplate Then
Console.WriteLine("The fingerprint template belongs to the owner.")
Else
Console.WriteLine("The fingerprint template does not belong to the owner.")
End If
Else
Console.WriteLine("Failed to read the fingerprint template from the machine.")
End If
' Disconnect from the machine
zkem.Disconnect()
Else
Console.WriteLine("Failed to connect to the ZKTeco machine.")
End If
End Sub
Private Function ReadFingerprintTemplate() As Byte()
Dim templateData As Byte() = Nothing
Dim userID As Integer = 1 ' Replace with the owner's user ID
' Read the fingerprint template from the machine
Dim isSuccess As Boolean = zkem.GetUserTmpExStr(1, userID, 0, templateData, 0, 0)
If isSuccess Then
Return templateData
Else
Return Nothing
End If
End Function
Private Function VerifyOwnerTemplate(ByVal templateData As Byte()) As Boolean
' Perform owner verification logic here
' You would typically compare the template data with the stored owner's fingerprint template in your application's database
' Dummy implementation for demonstration purposes
Dim storedTemplateData As Byte() = GetStoredOwnerTemplate() ' Replace with the stored owner's fingerprint template
' Compare the template data
If storedTemplateData IsNot Nothing AndAlso templateData IsNot Nothing AndAlso storedTemplateData.Length = templateData.Length Then
For i As Integer = 0 To storedTemplateData.Length - 1
If storedTemplateData(i) <> templateData(i) Then
Return False
End If
Next
Return True
Else
Return False
End If
End Function
Private Function GetStoredOwnerTemplate() As Byte()
' Retrieve the stored owner's fingerprint template from your application's database
' Replace this implementation with your actual database retrieval logic
' Dummy implementation for demonstration purposes
' This is an example template data; replace it with the actual stored owner's template
Dim ownerTemplateData As Byte() = New Byte() {1, 2, 3, 4, 5}
Return ownerTemplateData
End Function
End Class