Step On Hoe to access smartcard
11.11.06 (11:35 pm) [edit]
Below are the steps which we can perform to access Smart Card:
- Use the SCardEstablishContext API to get a Context Handle associated with a reader. We get this handle as all other API functions in WicSCard.dll need to pass this handle as a parameter.
- Later using the SCardConnect API you obtain hCard that is handle to a card. Just like above we will need this handle to communicate with the Card.
- You may then use SCardStatus with the above hCard value to get the status of the card before you actually start with some transaction.
- You then use SCardTransmit API to send APDU to the associated card and retrieve the response at the same time. You'll need the hCard value here too.
- After you're done using the Card you use the SCardDisconnect API to disconnect from the Card using the hCard value associated with the card. Then this hCard value is no longer valid and you should do a SCardConnect call again to retrieve a new handle in case you want to reconnect again
- Finally when you don't need the connection with the reader device you just call the SCardReleaseContext API to release the Context handle associated with the reader.