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
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