<div dir="ltr"><div><div><div><div><div>Hey guys,<br><br></div>do you know what is the proper way to detect when a smart card is inserted?<br><br></div>in some places I've seen something like this:<br><br>rgReaderStates[0].szReader = &mszReaders[iList[iReader]];<br>rgReaderStates[0].dwCurrentState = SCARD_STATE_EMPTY;<br><br>rv = SCardGetStatusChange(hContext, INFINITE, rgReaderStates, 1);<br><br></div>while this worked for me on linux with pcsclite it does not seem to work for me on windows, while doing this next does:<br>rgReaderStates[0].szReader = &mszReaders[iList[iReader]];<br>rgReaderStates[0].dwCurrentState = SCARD_STATE_UNAWARE;<br><br>rv = SCardGetStatusChange(hContext, INFINITE, rgReaderStates, 1);<br><br>if (rv == SCARD_S_SUCCESS) {<br>  rgReaderStates[0].dwCurrentState = rgReaderStates[0].dwEventState;<br>}<br><br>rv = SCardGetStatusChange(hContext, INFINITE, rgReaderStates, 1);<br><br></div>As you can see I need to do the call twice, first to get the current state and second to actually block to wait for the smart card to be inserted. Is this second way the recommended way also on pcsclite? If yes is the first version shown here in this mail some kind of shortcut for the 2 way call?<br></div><div>Is there a better way to check when a smart card is inserted?<br></div><div><br></div>Thanks in advance.<br clear="all"><div><div><div><div><div><div><div><br>-- <br><div dir="ltr"><div>Ignacio Casal Quinteiro<br></div></div>
</div></div></div></div></div></div></div></div>