VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "Match"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
Public Function FPIdentify(strPath As String, strName As String, strIdentifyModel As String) As String
    Dim m_strSample As String, iPos As Integer, i As Integer
    Dim dLen As Long
    
    On Error Resume Next
    FPIdentify = Str(FTR_RETCODE_INITIALIZATION_FAILED) + "?"
    If Not Initialize() Then
        Exit Function
    End If
                        
    Set fso = CreateObject("Scripting.FileSystemObject")
    If Not fso.FolderExists(strPath) Then
        Set fso = Nothing
        FPIdentify = Str(FTR_RETCODE_PATH_NOT_EXIST) + "?"
        Exit Function
    End If
    Set fso = Nothing
                        
    m_strSample = strIdentifyModel
    iPos = InStr(1, m_strSample, "$")
    If (iPos > 0) Then
        dLen = Mid(m_strSample, 1, iPos - 1)
        m_strSample = Right(m_strSample, Len(m_strSample) - iPos)
    Else
        FPIdentify = Str(FTR_RETCODE_DATA_INVALID) + "?"
        Exit Function
    End If
    
    ReDim g_MatchTemplate(dLen) As Byte
    i = 0
    Do While Len(m_strSample) > 0
        iPos = InStr(1, m_strSample, "$")
        If (iPos > 0) Then
            g_MatchTemplate(i) = Mid(m_strSample, 1, iPos - 1)
            m_strSample = Right(m_strSample, Len(m_strSample) - iPos)
            i = i + 1
        Else
            Exit Do
        End If
    Loop
    g_Sample.dwSize = dLen
    g_Sample.pData = VarPtr(g_MatchTemplate(0))
       
    MatchIdentify strPath, strName
    
    FPIdentify = Str(g_iRetCode) + "?" + g_strNameFound
    
End Function

Public Function FpEnroll(strPath As String, strUserName As String, strFingerName As String, strEnrollTemplate As String) As Integer
    Dim m_strTemplate As String, iPos As Integer, i As Integer
    Dim dwLen As Long
    Dim szPath As String
    Dim FileNumber As Integer
    Dim key As String * 16
    
    On Error Resume Next
    If Not Initialize() Then
        FpEnroll = FTR_RETCODE_INITIALIZATION_FAILED
        Exit Function
    End If
    
    szPath = strPath + "\" + strUserName + "_" + strFingerName + ".tml"
    Set fso = CreateObject("Scripting.FileSystemObject")
    If Not fso.FolderExists(strPath) Then
        Set fso = Nothing
        FpEnroll = FTR_RETCODE_PATH_NOT_EXIST
        Exit Function
    End If
    
    If (fso.FileExists(szPath)) Then
        Set fso = Nothing
        FpEnroll = FTR_RETCODE_FILE_EXIST
        Exit Function
    End If
    Set fso = Nothing
    
    m_strTemplate = strEnrollTemplate
    
    iPos = InStr(1, m_strTemplate, "$")
    If (iPos > 0) Then
        dwLen = Mid(m_strTemplate, 1, iPos - 1)
        m_strTemplate = Right(m_strTemplate, Len(m_strTemplate) - iPos)
    Else
        FpEnroll = FTR_RETCODE_DATA_INVALID
        Exit Function
    End If
        
    ReDim g_MatchTemplate(dwLen) As Byte
    i = 0
    Do While Len(m_strTemplate) > 0
        iPos = InStr(1, m_strTemplate, "$")
        If (iPos > 0) Then
            g_MatchTemplate(i) = Mid(m_strTemplate, 1, iPos - 1)
            m_strTemplate = Right(m_strTemplate, Len(m_strTemplate) - iPos)
            i = i + 1
        Else
            Exit Do
        End If
    Loop
      
    key = strUserName
    FileNumber = FreeFile
    Open szPath For Binary Access Write As #FileNumber
    Put #FileNumber, , dwLen
    Put #FileNumber, , key
    Put #FileNumber, , g_MatchTemplate
    Close #FileNumber
    FpEnroll = FTR_RETCODE_OK
End Function

Private Function Initialize() As Boolean
    Dim rCode As Integer
    Dim value As Long
    
    On Error Resume Next
    value = FSD_FUTRONIC_USB
    Initialize = True
    ' initialize SDK
    rCode = FTRInitialize
    If rCode <> FTR_RETCODE_OK Then
        Initialize = False
        Exit Function
    End If
    ' FAR setting
    value = 110000
    rCode = FTRSetParam(FTR_PARAM_MAX_FAR_REQUESTED, value)
    If rCode <> FTR_RETCODE_OK Then
        Initialize = False
    End If
End Function

Private Sub Class_Terminate()
    FTRTerminate
    MsgBox "Class_Terminate FTRTerminate"
    Stop
    MsgBox "Class_Terminate Stop"
End Sub

