Welcome Guest ( Log In | Register )

Outline · [ Standard ] · Linear+

> MyKad Application, Need to capture data, how?

post Feb 26 2009, 01:28 PM

New Member
2 posts

Joined: Feb 2009

Hi xenon,

Great job on the winscard code, really helped me a lot.

I have a problem here, i want to write the same code for reading mykad using vb.net. I got the connection, reader name and the ATR working, but i just couldn't get the rest. Could you please help me out here? I know it's been a long time since you've posted this post, but i'm bumped. I got -2146435068 for ReturnCode and my RxBuf returns all 0. Could you look through the code below n point out where i got it wrong? Appreciate it!


Public Sub checkCard()
           Dim SendRequest As SCARD_IO_REQUEST
           Dim RecvRequest As SCARD_IO_REQUEST
           Dim sTemp As String
           Dim icount As Integer

           SendRequest.dwProtocol = SCARD_PROTOCOL_T0
           SendRequest.cbPciLength = Len(SendRequest)
           RecvRequest.dwProtocol = SCARD_PROTOCOL_T0
           RecvRequest.cbPciLength = Len(RecvRequest)
           TxBuf = New Byte() {&H0, &HA4, &H4, &H0, &HA, &HA0, &H0, &H0, &H0, &H74, &H4A, &H50, &H4E, &H0, &H10}
           RxBufLen = 256

           ReturnCode = winSCard.SCardTransmit(hCard, SendRequest, TxBuf(0), 15, RecvRequest, RxBuf(0), RxBufLen)
           filewriter.WriteLine("Return Code : " + ReturnCode)
           sTemp = ""
           For icount = 0 To 14
               sTemp = sTemp + Format(Hex(TxBuf(icount)), "") + " "
           Next icount
           filewriter.WriteLine("Send Buffer : " + sTemp)
           sTemp = ""
           For icount = 0 To RxBufLen - 1
               sTemp = sTemp + Format(Hex(RxBuf(icount)), "") + " "
           Next icount
           filewriter.WriteLine("Receive Buffer : " + sTemp)
End Sub

post Feb 27 2009, 11:20 AM

New Member
2 posts

Joined: Feb 2009

Thanks xenon, for your reply. I found out what went wrong though. The only difference I find with ur scdump.c code and mine is i send 2 different variable for the SCARD_IO_REQUEST and yours send the same. So it shud look like this.

winSCard.SCardTransmit(hCard, Request, TxBuf(0), 15, Request, RxBuf(0), RxBufLen)

And that got all the data from MyKad!! Superb!!


Switch to:
| Lo-Fi Version
0.0315sec    1.37    7 queries    GZIP Disabled
Time is now: 16th December 2019 - 02:50 AM