Hello all,

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:

#include <stdio.h>
#include <PCSC/pcsclite.h>
#include <stdlib.h>

int main() {

  SCARDCONTEXT hContext;
  SCARDHANDLE hCard;
  char *lpcReaders;
  DWORD dwReaders;
  DWORD dwActive, dwState, dwRlen;
  DWORD dwProtocol, dwAtrLen;
  BYTE Atr[MAX_ATR_SIZE];

  SCardEstablishContext( SCARD_SCOPE_SYSTEM, 0, 0,
              &hContext );

   dwReaders  = 0;
   lpcReaders = 0;

   SCardListReaders( hContext, 0, NULL, &dwReaders );
   lpcReaders = (char *)malloc(sizeof(char)*dwReaders);
   SCardListReaders( hContext, 0, lpcReaders, &dwReaders );

   SCardConnect( hContext, lpcReaders, SCARD_SHARE_EXCLUSIVE,
        SCARD_PROTOCOL_T0,
        &hCard, &dwActive );

   dwState = 0;

// here lpcReaders prints the value "OmniKey CardMan 3121 00 00"
// This 00 00 should be there? I think the problem is here...

   SCardStatus( hCard, lpcReaders, &dwReaders, &dwState, &dwProtocol,
        Atr, &dwAtrLen );

   SCardDisconnect( hCard, SCARD_UNPOWER_CARD );
   SCardReleaseContext( hContext );

   if ( dwState & SCARD_PRESENT ) {
       return 1;
   }

    return 0;
}

This code compiles and execute without an error... but it does not detect
the presence of the smartcard. Any ideas?


thanks, global
_______________________________________________
Muscle mailing list
[email protected]
http://lists.drizzle.com/mailman/listinfo/muscle

Reply via email to