Es gibt ja noch die Möglichkeit zur Ansteuerung über PC/SC alternativ zur CT-API.
Aber ich bin schon etwas weiter gekommen mit der CT-API.
Beim Ausführen der Methode GetCardMonStatus() erhalte ich den Fehler "Tag 80". Was bedeutet das?
Bevor jemand fragt: Das Kartenlesegerät ist angeschlossen und es steckt eine Versichertenkarte drin.
Der Fehler tritt hier auf (siehe Kommentar im Code):
Const CT_DEST_CARD = 0
Const CT_DEST_CT = 1
Const CT_DEST_APPLICATION = 2
Declare Function init Lib "Ctrsct32" Alias "CT_init" (ctn As UInt16, pn As UInt16) As Int8
Declare Function data Lib "Ctrsct32" Alias "CT_data" (ctn As UInt16, ByRef dad As Int8, ByRef sad As Int8, lenc As UInt16, command As Ptr, ByRef lenr As UInt16, response As Ptr) As Int8
Declare Function close1 Lib "Ctrsct32" Alias "CT_close" (ctn As UInt16) As Int8
Var Dad As Int8 = CT_DEST_CT
Var Sad As Int8 = CT_DEST_APPLICATION
Var nRelevantByte As Integer = 0
Var Cmd As New MemoryBlock(5)
Cmd.Int8Value(0) = &h20
Cmd.Int8Value(1) = &h13
Cmd.Int8Value(2) = &h00
Cmd.Int8Value(3) = &h80
Cmd.Int8Value(4) = &h00
Var Lc As UInt16 = Cmd.Size
Var Rsp As New MemoryBlock(65535)
Var Lr As UInt16 = Rsp.Size
Var nRet As Integer = -1
nRet = data(1, Dad, Sad, Lc, Cmd, lr, Rsp)
If nRet < 0 Then
Return "error nret < 0"
End If
If Lr < 3 Then
return "error lr < 3"
End If
If CType((Rsp.Int8Value(lr - 2) * &h0100) + (Rsp.Int8Value(Lr - 1)), UInt16) <> &h9000 Then
Return "error h0100"
End If
Select Case Lr
Case 3
nRelevantByte = 0
Case 4
nRelevantByte = 0
Case 5
If ((Rsp.Int8Value(0) <> &h80) Or (Rsp.Int8Value(1) <> &h01)) Then
return "error h80" // hier tritt der Fehler auf
End If
nRelevantByte = 2
Else
Return "error default case"
End Select
If CType(rsp.Int8Value(nRelevantByte) And 1, Boolean) Then
return "Card inserted"
Else
return "Card released"
End If