⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmmain.frm

📁 磁条读写机
💻 FRM
📖 第 1 页 / 共 2 页
字号:
    ReportError
End If
End Sub

Private Sub btnExecuteApdu_Click()

Dim Apdu As APDUSTRUCT
Dim ch As Byte

SCHelp_HexStringToBytes txtCLA.Text, Apdu.Cla, 1
SCHelp_HexStringToBytes txtINS.Text, Apdu.Ins, 1
SCHelp_HexStringToBytes txtP1.Text, Apdu.P1, 1
SCHelp_HexStringToBytes txtP2.Text, Apdu.P2, 1
SCHelp_HexStringToBytes txtLC.Text, ch, 1
Apdu.lc = ch
SCHelp_HexStringToBytes HexCmdBuf.Text, Apdu.DataBuf(0), Apdu.lc
SCHelp_HexStringToBytes txtLE.Text, ch, 1
Apdu.Le = ch

If SC7816_ExecuteAPDU(hPort, Apdu) Then
    HexRspBuf.Text = ArrToHexStr(Apdu.DataBuf, Apdu.Le)
    Dim tpval As String
    tpval = Space(2)
    SCHelp_BytesToHexString Apdu.SW1, 1, tpval
    txtSW1.Text = tpval
    tpval = Space(2)
    SCHelp_BytesToHexString Apdu.SW2, 1, tpval
    txtSW2.Text = tpval
Else
    ReportError
End If

End Sub

Private Sub btnExecuteTpdu_Click()
Dim TpduCmdBuf(260) As Byte
Dim TpduRspBuf(260) As Byte
Dim lCmdSize As Long
Dim lRspSize As Long
SCHelp_HexStringToBytes txtCLA.Text, TpduCmdBuf(0), 1
SCHelp_HexStringToBytes txtINS.Text, TpduCmdBuf(1), 1
SCHelp_HexStringToBytes txtP1.Text, TpduCmdBuf(2), 1
SCHelp_HexStringToBytes txtP2.Text, TpduCmdBuf(3), 1
SCHelp_HexStringToBytes txtLC.Text, TpduCmdBuf(4), 1
If TpduCmdBuf(4) <> 0 Then
    SCHelp_HexStringToBytes HexCmdBuf.Text, TpduCmdBuf(5), TpduCmdBuf(4)
    lCmdSize = 5 + TpduCmdBuf(4)
Else
    SCHelp_HexStringToBytes txtLE.Text, TpduCmdBuf(4), 1
    lCmdSize = 5
End If

lRspSize = 258
If SC7816_ExecuteTPDU(hPort, TpduCmdBuf(0), lCmdSize, TpduRspBuf(0), lRspSize) Then
    HexRspBuf.Text = ArrToHexStr(TpduRspBuf, lRspSize - 2)
    Dim tpval As String
    tpval = Space(2)
    SCHelp_BytesToHexString TpduRspBuf(lRspSize - 2), 1, tpval
    txtSW1.Text = tpval
    tpval = Space(2)
    SCHelp_BytesToHexString TpduRspBuf(lRspSize - 1), 1, tpval
    txtSW2.Text = tpval
Else
    ReportError
End If

End Sub

Private Sub btnReConnect_Click()
Dim ATR(32) As Byte
If 0 = SC_Connect(hPort, "ISO7816-4", "", ATR(0)) Then
    ReportError
Else
    If SC7816_GetProtocol(hPort) = SCPROT_T0 Then
        cmbProtocol.ListIndex = 0
    Else
        cmbProtocol.ListIndex = 1
    End If
End If
End Sub

Private Sub btnReset_Click()
Dim ATR(32) As Byte
Dim atrLen As Long
atrLen = 32
If SC7816_WarmReset(hPort, ATR(0), atrLen) Then
    HexRspBuf.Text = ArrToHexStr(ATR, atrLen)
Else
    ReportError
End If

End Sub

Private Sub cmbProtocol_Click()
On Error GoTo ErrFlag
If cmbProtocol.ListIndex = 0 Then
    btnExecuteTpdu.Enabled = True
    If SC7816_GetProtocol(hPort) = SCPROT_T1 Then
        If SC7816_SetProtocol(hPort, SCPROT_T0) = 0 Then
            GoTo ErrFlag
        End If
    End If
Else
    btnExecuteTpdu.Enabled = False
    If SC7816_GetProtocol(hPort) = SCPROT_T0 Then
        If SC7816_SetProtocol(hPort, SCPROT_T1) = 0 Then
            GoTo ErrFlag
        End If
    End If
End If

Exit Sub
ErrFlag:
    ReportError
    If SC7816_GetProtocol(hPort) = SCPROT_T1 Then
       cmbProtocol.ListIndex = 1
    Else
       cmbProtocol.ListIndex = 0
    End If
End Sub

Private Sub Form_Load()
OpenReader
End Sub

Private Sub Form_Unload(Cancel As Integer)
SC_CloseReader hPort
End Sub

Private Sub txtLC_KeyPress(KeyAscii As Integer)
With txtLC

    If KeyAscii = vbKeyUp Or KeyAscii = vbKeyDown Or KeyAscii = vbKeyRight Or KeyAscii = vbKeyLeft Or KeyAscii = vbKeyEnd Or KeyAscii = vbKeyHome Or KeyAscii = vbKeyPageDown Or KeyAscii = vbKeyPageUp Then
        Exit Sub
    End If
    If KeyAscii = vbKeyBack Then
        KeyAscii = 0
        If .SelStart <> 0 Then
            .SelStart = .SelStart - 1
            .SelLength = 1
            .SelText = "0"
            .SelStart = .SelStart - 1
        End If
    ElseIf (KeyAscii >= Asc("0") And KeyAscii <= Asc("9")) _
        Or (KeyAscii >= Asc("A") And KeyAscii <= Asc("F")) _
        Or (KeyAscii >= Asc("a") And KeyAscii <= Asc("f")) Then
    
        '大小写转换
        If KeyAscii >= Asc("a") And KeyAscii <= Asc("f") Then
            KeyAscii = KeyAscii + Asc("A") - Asc("a")
        End If
        
    
        If .SelStart < .MaxLength Then
            .SelLength = 1
            .SelText = Chr$(KeyAscii)
        End If

    
    End If
    
    KeyAscii = 0
    .SelLength = 0

End With
End Sub


Private Sub txtLC_LostFocus()
Dim lc As Byte
SCHelp_HexStringToBytes txtLC.Text, lc, 1
HexCmdBuf.BufferSize = lc
End Sub



Private Sub txtLE_KeyPress(KeyAscii As Integer)
With txtLE

    If KeyAscii = vbKeyUp Or KeyAscii = vbKeyDown Or KeyAscii = vbKeyRight Or KeyAscii = vbKeyLeft Or KeyAscii = vbKeyEnd Or KeyAscii = vbKeyHome Or KeyAscii = vbKeyPageDown Or KeyAscii = vbKeyPageUp Then
        Exit Sub
    End If
    If KeyAscii = vbKeyBack Then
        KeyAscii = 0
        If .SelStart <> 0 Then
            .SelStart = .SelStart - 1
            .SelLength = 1
            .SelText = "0"
            .SelStart = .SelStart - 1
        End If
    ElseIf (KeyAscii >= Asc("0") And KeyAscii <= Asc("9")) _
        Or (KeyAscii >= Asc("A") And KeyAscii <= Asc("F")) _
        Or (KeyAscii >= Asc("a") And KeyAscii <= Asc("f")) Then
    
        '大小写转换
        If KeyAscii >= Asc("a") And KeyAscii <= Asc("f") Then
            KeyAscii = KeyAscii + Asc("A") - Asc("a")
        End If
        
    
        If .SelStart < .MaxLength Then
            .SelLength = 1
            .SelText = Chr$(KeyAscii)
        End If

    
    End If
    
    KeyAscii = 0
    .SelLength = 0

End With
End Sub

Private Sub txtP1_KeyPress(KeyAscii As Integer)
With txtP1

    If KeyAscii = vbKeyUp Or KeyAscii = vbKeyDown Or KeyAscii = vbKeyRight Or KeyAscii = vbKeyLeft Or KeyAscii = vbKeyEnd Or KeyAscii = vbKeyHome Or KeyAscii = vbKeyPageDown Or KeyAscii = vbKeyPageUp Then
        Exit Sub
    End If
    If KeyAscii = vbKeyBack Then
        KeyAscii = 0
        If .SelStart <> 0 Then
            .SelStart = .SelStart - 1
            .SelLength = 1
            .SelText = "0"
            .SelStart = .SelStart - 1
        End If
    ElseIf (KeyAscii >= Asc("0") And KeyAscii <= Asc("9")) _
        Or (KeyAscii >= Asc("A") And KeyAscii <= Asc("F")) _
        Or (KeyAscii >= Asc("a") And KeyAscii <= Asc("f")) Then
    
        '大小写转换
        If KeyAscii >= Asc("a") And KeyAscii <= Asc("f") Then
            KeyAscii = KeyAscii + Asc("A") - Asc("a")
        End If
        
    
        If .SelStart < .MaxLength Then
            .SelLength = 1
            .SelText = Chr$(KeyAscii)
        End If

    
    End If
    
    KeyAscii = 0
    .SelLength = 0

End With
End Sub
Private Sub txtP2_KeyPress(KeyAscii As Integer)
With txtP2

    If KeyAscii = vbKeyUp Or KeyAscii = vbKeyDown Or KeyAscii = vbKeyRight Or KeyAscii = vbKeyLeft Or KeyAscii = vbKeyEnd Or KeyAscii = vbKeyHome Or KeyAscii = vbKeyPageDown Or KeyAscii = vbKeyPageUp Then
        Exit Sub
    End If
    If KeyAscii = vbKeyBack Then
        KeyAscii = 0
        If .SelStart <> 0 Then
            .SelStart = .SelStart - 1
            .SelLength = 1
            .SelText = "0"
            .SelStart = .SelStart - 1
        End If
    ElseIf (KeyAscii >= Asc("0") And KeyAscii <= Asc("9")) _
        Or (KeyAscii >= Asc("A") And KeyAscii <= Asc("F")) _
        Or (KeyAscii >= Asc("a") And KeyAscii <= Asc("f")) Then
    
        '大小写转换
        If KeyAscii >= Asc("a") And KeyAscii <= Asc("f") Then
            KeyAscii = KeyAscii + Asc("A") - Asc("a")
        End If
        
    
        If .SelStart < .MaxLength Then
            .SelLength = 1
            .SelText = Chr$(KeyAscii)
        End If

    
    End If
    
    KeyAscii = 0
    .SelLength = 0

End With
End Sub

Private Sub txtCLA_KeyPress(KeyAscii As Integer)
With txtCLA

    If KeyAscii = vbKeyUp Or KeyAscii = vbKeyDown Or KeyAscii = vbKeyRight Or KeyAscii = vbKeyLeft Or KeyAscii = vbKeyEnd Or KeyAscii = vbKeyHome Or KeyAscii = vbKeyPageDown Or KeyAscii = vbKeyPageUp Then
        Exit Sub
    End If
    If KeyAscii = vbKeyBack Then
        KeyAscii = 0
        If .SelStart <> 0 Then
            .SelStart = .SelStart - 1
            .SelLength = 1
            .SelText = "0"
            .SelStart = .SelStart - 1
        End If
    ElseIf (KeyAscii >= Asc("0") And KeyAscii <= Asc("9")) _
        Or (KeyAscii >= Asc("A") And KeyAscii <= Asc("F")) _
        Or (KeyAscii >= Asc("a") And KeyAscii <= Asc("f")) Then
    
        '大小写转换
        If KeyAscii >= Asc("a") And KeyAscii <= Asc("f") Then
            KeyAscii = KeyAscii + Asc("A") - Asc("a")
        End If
        
    
        If .SelStart < .MaxLength Then
            .SelLength = 1
            .SelText = Chr$(KeyAscii)
           ' .SelStart = .SelStart + 1
        End If

    
    End If
    
    KeyAscii = 0
    .SelLength = 0

End With
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -