Thanks for all answers... I could do it with this code below:
SCARDCONTEXT hContext;
SCARD_READERSTATE_A rgReaderStates[1];
char *lpcReaders = NULL;
DWORD dwReaders = 0;
LONG rv;
SCardEstablishContext (SCARD_SCOPE_SYSTEM, 0, 0, &hContext);
// get the cardreaders connected
SCardListReaders (hContext, 0, NULL, &dwReaders);
lpcReaders = (char *) malloc (sizeof (char) * dwReaders);
SCardListReaders (hContext, 0, lpcReaders, &dwReaders);
rgReaderStates[0].szReader = lpcReaders;
rgReaderStates[0].dwCurrentState = SCARD_STATE_UNAWARE;
rv = SCardGetStatusChange (hContext, INFINITE, rgReaderStates, 1);
#ifdef __DEBUG__
printf ("reader state: 0x%04X\n", rgReaderStates[0].dwEventState);
#endif
// check if card is present
if (rgReaderStates[0].dwEventState & SCARD_STATE_PRESENT)
return 1;
On Wed, Apr 14, 2010 at 4:08 AM, Martin Paljak <[email protected]> wrote:
> On Apr 13, 2010, at 22:51 , Anderson Goulart wrote:
> > I am trying to use pcsclite API just to check if the card is inserted on
> the reader or not, based on the API reference and some example codes at
> muscle site:
>
> ...
> >
> >
> > SCardConnect( hContext, lpcReaders, SCARD_SHARE_EXCLUSIVE,
> > SCARD_PROTOCOL_T0,
> > &hCard, &dwActive );
>
> ...
> > SCardStatus( hCard, lpcReaders, &dwReaders, &dwState, &dwProtocol,
> > Atr, &dwAtrLen );
>
>
> You might want to use SCardGetStatusChange [1] which does not require an
> open connection to the card in the first place (a card handle)
>
> [1] http://pcsclite.alioth.debian.org/pcsc-lite/node20.html
>
>
When I use SCardGetStatusChange, it returns always the same result: 0x0006.
_______________________________________________
Muscle mailing list
[email protected]
http://lists.drizzle.com/mailman/listinfo/muscle