Private Sub Read(sender As Object, e As EventArgs) Handles MyBase.Load
Dim ReaderCount As Integer
Dim ReaderCount As Integer
Dim ctr As Integer
Dim sReaderList As String
Dim ctr As Integer
Dim sReaderList As String
For ctr = 0 To 255
sReaderList = sReaderList + vbNullChar
Next
ReaderCount = 255
' 1. Establish context and obtain hContext handle
retCode = ModWinsCard.SCardEstablishContext(ModWinsCard.SCARD_SCOPE_USER, 0, 0, hContext)
' 2. List PC/SC card readers installed in the system
retCode = ModWinsCard.SCardListReaders(hContext, "", sReaderList, ReaderCount)
' Load Available Readers
Call LoadListToControl(cbReader, sReaderList)
cbReader.SelectedIndex = 0
If connActive Then
retCode = ModWinsCard.SCardDisconnect(hCard, ModWinsCard.SCARD_UNPOWER_CARD)
End If
' Shared Connection
retCode = ModWinsCard.SCardConnect(hContext, cbReader.SelectedItem.ToString(), ModWinsCard.SCARD_SHARE_SHARED, ModWinsCard.SCARD_PROTOCOL_T0 Or ModWinsCard.SCARD_PROTOCOL_T1, hCard, Protocol)
connActive = True
Connect()
End Sub
Public Sub Connect()
Dim tmpStr As String
Dim indx As Integer
validATS = False
Call ClearBuffers()
SendBuff(0) = &HFF ' CLA
SendBuff(1) = &HCA ' INS
SendBuff(3) = &H0 ' P2
SendBuff(4) = &H0 ' Le : Full Length
SendLen = SendBuff(4) + 5
RecvLen = &HFF
retCode = SendAPDUandDisplay(3)
If retCode <> ModWinsCard.SCARD_S_SUCCESS Then
Exit Sub
End If
For indx = 0 To (RecvLen - 3)
tmpStr = tmpStr + Microsoft.VisualBasic.Right("00" & Hex(RecvBuff(indx)), 2) + " "
Next indx
cardUID = tmpStr
Attendace_Menu.Show()
Me.Hide()
End Sub
Ich brauche Hilfe mit meinem Code. Ich möchte, dass es die UID der Smartcard nicht nur beim Laden des Formulars liest, sondern auch wenn ich die Karte entferne und sie wieder einfüge. Es liest nur die Karte, wenn ich das Formular lade. Ich habe keine Ahnung, was zu tun ist, da ich neu in der Programmierung bin und dies ist mein Projekt für die Schule.ACR122u Hilfe beim Lesen der Karte