Search code examples
smartcardsmartcard-readerpcsc

Detection of smart card removal and insertion using PCSC in C


I am using PCSC-lite v1.6.4 for my smartcard based application development. I need a way to detect as soon as smart card is removed from reader and then to detect the insertion into reader so that smartcard will be forced to complete a specific process again.

If possible, is there any interrupt/event based way instead of simple polling?


Solution

  • There is SCardGetStatusChange in WinSCard library.

    Blocks execution until the current availability of the cards in a specific set of readers changes.

    Since PCSC Lite is a reimplementation of WinSCard library you can also use it in PCSC Lite (here). You can find several examples.