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 SCardConnectA( SCARDCONTEXT hContext, LPCSTR szReader, DWORD dwShareMode, DWORD dwPreferredProtocols, LPSCARDHANDLE phCard, LPDWORD pdwActiveProtocol );
The name of the reader that contains the target card.
A flag that indicates whether other applications may form connections to the card.
A bitmask of acceptable protocols for the connection. Possible values may be combined with the OR operation.
||T=0 is an acceptable protocol.|
||T=1 is an acceptable protocol.|
||This parameter may be zero only if dwShareMode is set to SCARD_SHARE_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.|
A handle that identifies the connection to the smart card in the designated reader.
A flag that indicates the established active protocol.
||T=0 is the active protocol.|
||T=1 is the active protocol.|
||SCARD_SHARE_DIRECT has been specified, so that no protocol negotiation has occurred. It is possible that there is no card in the reader.|
This function returns different values depending on whether it succeeds or fails.
||An error code. For more information, see Smart Card Return Values.|
||The reader was unable to connect to the card.|
The following example creates a connection to a reader. The example assumes that hContext is a valid handle of type SCARDCONTEXT received from a previous call to SCardEstablishContext.
SCARDHANDLE hCardHandle; LONG lReturn; DWORD dwAP;
|Minimum supported client||Windows XP [desktop apps only]|
|Minimum supported server||Windows Server 2003 [desktop apps only]|