1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
Public Class Api
public sub new
end sub
'Déclaration de l'event
Public Event CardConnected(sender As Object, e As CardConnectedEventArgs)
'import de la fonction de polling de la dll
<DllImport("CscApi.dll", EntryPoint:="sSmartStartPollingEx", SetLastError:=True, CharSet:=CharSet.Ansi, ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Private Shared Function sSmartStartPollingEx(byval hCsc As System.UInt32, byval ucNumScenario As System.Byte, byval xAC As eTypACType, byval ucSpontCall As System.Byte, byval pvCallBackEx As fCallBackEx) As System.Int16
End Function
'déclaration du délégué de la fonction de callback
<UnmanagedFunctionPointerAttribute(CallingConvention.Cdecl)>
Private Delegate Sub fCallBackEx (ByVal hCsc As System.UInt32, byref pxStatusCSC As StatusCSC)
Public Sub CSCReaderStartPollingEx()
'Configuration de la routine de callback
Dim ProcedurepCallBackExFunc As New fCallBackEx(AddressOf Me.CallBackExFunc)
'fonction de l'API qui lance la detection (polling) sur le lecteur
ApiReturn = sSmartStartPollingEx(Me.CscReaderHandle,1,eTypACType.AC_WITHOUT_COLLISION,1,ProcedurepCallBackExFunc)
End Sub
'fonction de callback appelé par l'API (si j'ai bien compris le fonctionnement) lorsqu'une carte est posé sur le lecteur
Private Sub CallBackExFunc (ByVal hCsc As System.UInt32, byref pxStatusCSC As StatusCSC)
'Je déclenche l'event
RaiseEvent CardConnected(Me, New CardConnectedEventArgs(pxStatusCSC))
End Sub
End Class |
Partager