<div dir="ltr"><div><div><div><div><div>Hello ignacio<br><br></div><br>As you said, you have to call SCardGetStatusChange twice:<br></div>The first call get the current state of the readers, and has a timeout of 0.<br></div>The second call, with a timeout of INFINITE wait until any difference is detected.<br><br></div>Have a look at <a href="http://pcsclite.alioth.debian.org/api/group__API.html#ga33247d5d1257d59e55647c3bb717db24">http://pcsclite.alioth.debian.org/api/group__API.html#ga33247d5d1257d59e55647c3bb717db24</a><br><br></div><div>There are many tricky things you could do to improve the speed/trustworthy of the detection, so start with something basic before looking for performance.<br></div><div><br></div><br><br><br><br><div><div><div><div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Sep 15, 2014 at 2:18 PM, Ignacio Casal <span dir="ltr"><<a href="mailto:ignacio.casal@nice-software.com" target="_blank">ignacio.casal@nice-software.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><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.<span class=""><font color="#888888"><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></font></span></div>
<br>_______________________________________________<br>
Pcsclite-muscle mailing list<br>
<a href="mailto:Pcsclite-muscle@lists.alioth.debian.org">Pcsclite-muscle@lists.alioth.debian.org</a><br>
<a href="http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pcsclite-muscle" target="_blank">http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pcsclite-muscle</a><br></blockquote></div><br></div></div></div></div></div></div></div></div>