Hello,
Welcome to Microsoft Q&A!
I want to detect card insert/remove event in a card reader without having to poll using VC++.
You could try to check whether the rgReaderStates
contains SCARD_STATE_EMPTY
or SCARD_STATE_PRESENT
. The SCardGetStatusChange function blocks execution until the current availability of the cards in a specific set of readers changes. So, if you want to monitor the reader during program execution, you may need to call it in a separate thread.
According to the doc:SCardGetStatusChangeA function
To be notified of the arrival of a new smart card reader, set the szReader member of a SCARD_READERSTATE structure to "\?PnP?\Notification", and set all of the other members of that structure to zero.
If you set the szReader
member to "\?PnP?\Notification", each member of SCARD_READERSTATE structure
must be initialized to zero and then set to specific values as necessary.
Could you please provide a sample to help us reproduce the issue?
Thank you.
Jeanine
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.