Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_vb thread: Getting DataOut from ScardComand ?


Message #1 by carterrd@t... on Tue, 29 Oct 2002 03:30:37
I am using VB6 to write a smartcard application using the SCARD32.DLL.
I am using the attached code.  But I cannot retrieve the DATAOUT from
SCardCommand.  I get "0" as the only output.
How can I retrieve the true status from this APDU command?
It should be 90h 00h, any help appreciated.
Thanks
Rick
>>>>>>>>>>>VB code starts Here >>>>>>>
Private Declare Function SCardComand Lib "SCARD32" _
  (Handle As Long, ByVal cmd As String, CmdLen As Long, _
  ByVal DataIn As String, DataInLen As Long, _
  ByVal DataOut As String, DataOutLen As Long) As Long

Private Sub SendAPDU_Click()
  Dim InBuffer As String
  Dim OutBuffer As String
  Dim InLen As Long
  Dim OutLen As Long
  OutBuffer = String(20, 0)
  OutLen = Len(OutBuffer)

' APDU Command to VERIFY KEY
'   cla     F0
'   ins     2A
'   p1      00
'   p2      01
'   lc      08
'   datain  47 46 58 49 32 56 78 40

  InBuffer = _
      Chr(&HF0) + Chr(&H2A) + Chr(&H0) + Chr(&H1) _
    + Chr(&H8) _
    + Chr(&H47) + Chr(&H46) + Chr(&H58) + Chr(&H49) _
    + Chr(&H32) + Chr(&H56) + Chr(&H78) + Chr(&H40)
  InLen = Len(InBuffer)
  L = SCardComand(0, "Card,APDU", 0, InBuffer, InLen, OutBuffer, OutLen)
  If L = 0 Then Label1.Caption = OutBuffer Else DisplayError (L)

End Sub



  Return to Index