📄 mdumain.bas
字号:
Attribute VB_Name = "mduMain"
Option Explicit
Public hPort As Long
Public DataBuffer(128) As Byte
Public lCardType As Long
Sub Main()
hPort = -1
lCardType = ICCTYPE_INVALID
frmMain.Show
End Sub
Sub OpenReader()
hPort = SC_OpenReader("USB", "")
If (hPort < 0) Then
ReportError
End
Else
MsgBox "操作成功!"
End If
End Sub
Sub CloseReader()
SC_CloseReader hPort
End Sub
Sub DisConnect()
SC_DisConnect hPort, 0
End Sub
Sub Connect()
Dim strType As String
If lCardType = ICCTYPE_SLE4442 Then
strType = "SLE4442"
ElseIf lCardType = ICCTYPE_SLE4428 Then
strType = "SLE4428"
ElseIf lCardType = ICCTYPE_SC1604 Then
strType = "SC1604"
ElseIf lCardType = ICCTYPE_AT24 Then
strType = "AT24"
Else
MsgBox "不支持的卡!"
Exit Sub
End If
Dim atr(32) As Byte
If 0 <> SC_Connect(hPort, strType, "", atr(0)) Then
MsgBox "上电成功,可以进行读写操作!"
Else
ReportError
End If
End Sub
Sub TestCardType()
Dim atr(32) As Byte
lCardType = SC_AutoTest(hPort, "")
If lCardType = ICCTYPE_SLE4442 Then
MsgBox "SLE4442"
ElseIf lCardType = ICCTYPE_SLE4428 Then
MsgBox "SLE4428"
ElseIf lCardType = ICCTYPE_SC1604 Then
MsgBox "AT88SC1604"
ElseIf lCardType = ICCTYPE_AT24 Then
If 0 <> SC_Connect(hPort, "AT24", "", atr(0)) Then
If ICCSUBTYPE_AT24C01 = SCAT24_GetSubType(hPort) Then
MsgBox "AT24C01"
ElseIf ICCSUBTYPE_AT24C04 = SCAT24_GetSubType(hPort) Then
MsgBox "AT24C04"
ElseIf ICCSUBTYPE_AT24C08 = SCAT24_GetSubType(hPort) Then
MsgBox "AT24C08"
ElseIf ICCSUBTYPE_AT24C16 = SCAT24_GetSubType(hPort) Then
MsgBox "AT24C16"
End If
End If
ElseIf lCardType = ICCTYPE_ASYNC Then
If 0 <> SC_Connect(hPort, "ISO7816-4", "", atr(0)) Then
If SCPROT_T0 = SC7816_Getprotocol(hPort) Then
MsgBox "Cpu Card(T=0)"
Else
MsgBox "Cpu Card(T=1)"
End If
End If
ElseIf lCardType = ICCTYPE_INVALID Then
ReportError
Else
MsgBox "未知卡型!"
End If
End Sub
Sub ReportError()
Dim strDesc As String
strDesc = Space(1000)
SCHelp_ErrorDesc SC_GetLastError, strDesc, 1000
MsgBox "错误代码:" & SC_GetLastError & Chr(10) & Chr(13) & strDesc
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -