0

So .. I have pcsc-reader, smartcard and c++ code. Find readers, chose them, connect and get ATR - working greatfull.

but after ATR-get i need to get APDU request, this code

SCARD_IO_REQUEST ioRecv;
byte  pbRecvBuffer[255]; 
int pbRecvLength=255;
byte   pbSendBuffer[] ={ 0x00, 0xb0, 0x00, 0x00}; //any comand
int cbSendLength = sizeof(pbSendBuffer);//size of comand
ioRecv.cbPciLength = 255;
DWORD  dwSize=255; 

//our Transmit those return error
lReturn = SCardTransmit(hSC,
                        (LPCSCARD_IO_REQUEST)dwAP,
                        pbSendBuffer,
                cbSendLength,
                        NULL,
                        pbRecvBuffer,
                        &dwSize);

if(lReturn==SCARD_S_SUCCESS){
//do smt with pbRecvBuffer   
printf("success");
}
else {
    printf("error "); 
}

always return "error"... If you could help me or point out my error, I would be very grateful.

Thank you

ollo
  • 24,797
  • 14
  • 106
  • 155
MIsha Ku
  • 1
  • 2
  • Error was found in first param of SCardTransmit() - According to the description of MSDN in SCardTransmit () does not need to pass a hSC. so have to pass m_hCardHandle received from SCardConnect (). also it wrong to pass (LPCSCARD_IO_REQUEST)dwAP. – MIsha Ku Feb 19 '13 at 06:53
  • So did this solve your error? If so, post it as an answer for posterity. You may even accept your own answers after a while, although you won't get points for it (I will vote up though). – Maarten Bodewes Feb 20 '13 at 20:28

1 Answers1

0

Error was found in first param of SCardTransmit() - According to the description of MSDN in SCardTransmit () does not need to pass a hSC. so have to pass m_hCardHandle received from SCardConnect (). also it wrong to pass (LPCSCARD_IO_REQUEST)dwAP

yap. It have solve the problem

MIsha Ku
  • 1
  • 2