Attribute VB_Name = "Module1"
'//************************************************************************/
'// [Caution]: this sample is only a demo how to install ePass1000 driver and middleware,
'//***********************************************************************/
Option Explicit

Global Const NOTIFY_DELETEFILE_REBOOT = 1
Global Const NOTIFY_DELETEFILE_RETRY = 2
Global Const NOTIFY_DELETEFILE_CANCEL = 3

Declare Sub esa_drv_SetDeleteFileCallback Lib "ePsInst_drv.dll" Alias "esa_SetDeleteFileCallback" (ByVal fNotify As Long)
Declare Sub esa_drv_SetShowMsgNotifyCallback Lib "ePsInst_drv.dll" Alias "esa_SetShowMsgNotifyCallback" (ByVal fNotify As Long)
Declare Sub esa_drv_SetShowErrMsgNotifyCallback Lib "ePsInst_drv.dll" Alias "esa_SetShowErrMsgNotifyCallback" (ByVal fNotify As Long)

Declare Sub esa_mw_SetDeleteFileCallback Lib "ePsInst_Mw.dll" Alias "esa_SetDeleteFileCallback" (ByVal fNotify As Long)
Declare Sub esa_mw_SetShowMsgNotifyCallback Lib "ePsInst_Mw.dll" Alias "esa_SetShowMsgNotifyCallback" (ByVal fNotify As Long)
Declare Sub esa_mw_SetShowErrMsgNotifyCallback Lib "ePsInst_Mw.dll" Alias "esa_SetShowErrMsgNotifyCallback" (ByVal fNotify As Long)

Declare Function esa_drv_DoInstall Lib "ePsInst_drv.dll" Alias "esa_DoInstall" (ByVal strPram As String) As Boolean
Declare Function esa_drv_DoUninstall Lib "ePsInst_drv.dll" Alias "esa_DoUninstall" (ByVal strPram As String) As Boolean

Declare Function esa_mw_DoInstall Lib "ePsInst_Mw.dll" Alias "esa_DoInstall" (ByVal strPram As String) As Boolean
Declare Function esa_mw_DoUninstall Lib "ePsInst_Mw.dll" Alias "esa_DoUninstall" (ByVal strPram As String) As Boolean

Declare Function esa_drv_IsNeedReboot Lib "ePsInst_drv.dll" Alias "esa_IsNeedReboot" () As Boolean
Declare Function esa_drv_LongToVbStr Lib "ePsInst_drv.dll" Alias "esa_LongToVbStr" (ByVal sText1 As String, ByVal sText2 As Long) As Long

Declare Function esa_mw_IsNeedReboot Lib "ePsInst_Mw.dll" Alias "esa_IsNeedReboot" () As Boolean
Declare Function esa_mw_LongToVbStr Lib "ePsInst_Mw.dll" Alias "esa_LongToVbStr" (ByVal sText1 As String, ByVal sText2 As Long) As Long

Function HelperLongToStr(ByVal hStr As Long) As String
Dim sTmp  As String * 512
Dim sRet  As String
Dim iLen  As Long

    iLen = esa_drv_LongToVbStr(sTmp, hStr)
    sRet = Mid(sTmp, 1, iLen)
    HelperLongToStr = sRet
End Function

Function MyDeleteProc(ByVal hStr As Long) As Long
    Dim strMsg As String
    
    strMsg = HelperLongToStr(hStr)
    MyDeleteProc = Form1.OnInstDelete(strMsg)
End Function

Sub MyProcessProc(ByVal hStr As Long)
    Dim strMsg As String
    
    strMsg = HelperLongToStr(hStr)
    Form1.OnInstProcess (strMsg)
End Sub

Sub MyErrProc(ByVal hStr As Long)
    Dim strMsg As String
    
    strMsg = HelperLongToStr(hStr)
    Form1.OnInstErr (strMsg)
End Sub

