Logo Search packages:      
Sourcecode: pcsc-lite version File versions  Download package

LONG SCardConnect ( SCARDCONTEXT  hContext,
LPCTSTR  szReader,
DWORD  dwShareMode,
DWORD  dwPreferredProtocols,
LPSCARDHANDLE  phCard,
LPDWORD  pdwActiveProtocol 
)

This function establishes a connection to the friendly name of the reader specified in szReader. The first connection will power up and perform a reset on the card.

Parameters:
[in] hContext Connection context to the PC/SC Resource Manager.
[in] szReader Reader name to connect to.
[in] dwShareMode Mode of connection type: exclusive or shared.
  • SCARD_SHARE_SHARED - This application will allow others to share the reader.
  • SCARD_SHARE_EXCLUSIVE - This application will NOT allow others to share the reader.
  • SCARD_SHARE_DIRECT - Direct control of the reader, even without a card. SCARD_SHARE_DIRECT can be used before using SCardControl() to send control commands to the reader even if a card is not present in the reader.
[in] dwPreferredProtocols Desired protocol use.
  • SCARD_PROTOCOL_T0 - Use the T=0 protocol.
  • SCARD_PROTOCOL_T1 - Use the T=1 protocol.
  • SCARD_PROTOCOL_RAW - Use with memory type cards.
dwPreferredProtocols is a bit mask of acceptable protocols for the connection. You can use (SCARD_PROTOCOL_T0 | SCARD_PROTOCOL_T1) if you do not have a preferred protocol.
[out] phCard Handle to this connection.
[out] pdwActiveProtocol Established protocol to this connection.
Returns:
Error code.
Return values:
SCARD_S_SUCCESS Successful.
SCARD_E_INVALID_HANDLE Invalid hContext handle.
SCARD_E_INVALID_VALUE Invalid sharing mode, requested protocol, or reader name.
SCARD_E_NOT_READY Could not allocate the desired port.
SCARD_E_READER_UNAVAILABLE Could not power up the reader or card.
SCARD_E_SHARING_VIOLATION Someone else has exclusive rights.
SCARD_E_UNSUPPORTED_FEATURE Protocol not supported.
Test:
 SCARDCONTEXT hContext;
 SCARDHANDLE hCard;
 DWORD dwActiveProtocol;
 LONG rv;
 ...
 rv = SCardEstablishContext(SCARD_SCOPE_SYSTEM, NULL, NULL, &hContext);
 rv = SCardConnect(hContext, "Reader X", SCARD_SHARE_SHARED, SCARD_PROTOCOL_T0, &hCard, &dwActiveProtocol);

Definition at line 344 of file winscard_scf.c.

References SCARD_EXCLUSIVE_CONTEXT, SCARD_NO_CONTEXT, SCARD_PROTOCOL_ANY_OLD, SCardLockThread(), SCardUnlockThread(), and SYS_USleep().

Referenced by MSGFunctionDemarshall().

{
      long rv;

      SCardLockThread();
      rv = SCardConnectTH(hContext, szReader, dwShareMode,
            dwPreferredProtocols, phCard, pdwActiveProtocol);
      SCardUnlockThread();
      return rv;
}


Generated by  Doxygen 1.6.0   Back to index