The SCardConnect function establishes a connection (using a specific resource manager context) between the calling application and a smart card contained by a specific reader. If no card exists in the specified reader, an error is returned.
LONG SCardConnect(
IN SCARDCONTEXT hContext,
IN LPCTSTR szReader,
IN DWORD dwShareMode,
IN DWORD dwPreferredProtocols,
OUT LPSCARDHANDLE phCard,
OUT LPDWORD pdwActiveProtocol
);
Value | Meaning |
---|---|
SCARDSHARE_SHARED | This application is willing to share the card with other applications. |
SCARDSHARE_EXCLUSIVE | This application is not willing to share the card with other applications. |
SCARDSHARE_DIRECT | This application is allocating the reader for its private use, and will be controlling it directly. No other applications are allowed access to it. |
Value | Meaning |
---|---|
SCARD_PROTOCOL_T0 | T=0 is an acceptable protocol. |
SCARD_PROTOCOL_T1 | T=1 is an acceptable protocol. |
0 | This parameter may be zero only if dwShareMode is set to SCARDSHARE_DIRECT. In this case, no protocol negotiation will be performed by the drivers until an IOCTL_SMARTCARD_SET_PROTOCOL control directive is sent with SCardControl. |
Value | Meaning |
---|---|
SCARD_PROTOCOL_T0 | T=0 is the active protocol. |
SCARD_PROTOCOL_T1 | T=1 is the active protocol. |
SCARD_PROTOCOL_UNKNOWN | SCARDSHARE_DIRECT has been specified, so that no protocol negotiation has occurred. It is possible that there is no card in the reader. |
If the function… | The return value is… |
---|---|
Succeeds | SCARD_S_SUCCESS. |
Fails | An error code (see Error Codes for a list of all error codes). |
SCardConnect is a smart card and reader access function. For a description of other access functions, see Smart Card and Reader Access Functions.
Windows NT: Use version 4.0 SP3 and later.
Windows: Use Windows 95 OSR2.1.
Windows CE: Unsupported.
Header: Declared in winscard.h.
Import Library: Link with winscard.lib.
SCardControl, SCardDisconnect, SCardEstablishContext, SCardReconnect