SCardConnect

This 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 );

Parameters

  • hContext
    Handle that identifies the resource manager context. The resource manager context is set by a previous call to SCardEstablishContext.

  • szReader
    Null-terminated string that specifies the name of the reader containing the target card.

  • dwShareMode
    Specifies a flag that indicates whether other applications can form connections to the card. The following list shows the possible values for dwShareMode.

    Value Description
    SCARD_SHARE_SHARED Unsupported.
    SCARD_SHARE_EXCLUSIVE This application is not willing to share the card with other applications.
    SCARD_SHARE_DIRECT Unsupported.
  • dwPreferredProtocols
    Specifies a bit mask of acceptable protocols for the connection. The following list shows the possible values, which may be combined with the OR operation, for dwPreferredProtocols.

    Value Description
    SCARD_PROTOCOL_T0 T=0 is an acceptable protocol.
    SCARD_PROTOCOL_T1 T=1 is an acceptable protocol.
    0 This parameter may be 0 only if dwShareMode is set to SCARD_SHARE_DIRECT. In this case, no protocol negotiation is performed by the drivers until an IOCTL_SMARTCARD_SET_PROTOCOL control directive is sent with SCardControl.
  • phCard
    Pointer to a handle that identifies the connection to the smart card in the designated reader.

  • pdwActiveProtocol
    Pointer to a DWORD that receives a flag indicating the established active protocol. The following list shows the possible values for pdwActiveProtocol.

    Value Description
    SCARD_PROTOCOL_T0 T=0 is the active protocol.
    SCARD_PROTOCOL_T1 T=1 is the active protocol.
    SCARD_PROTOCOL_UNKNOWN SCARD_SHARE_DIRECT has been specified, so that no protocol negotiation has occurred. It is possible that there is no card in the reader.

Return Values

Value Description
Succeeds SCARD_S_SUCCESS
Fails An error value (see Smart Card Error values for a list of all error values)

Remarks

SCardConnect is a smart card and reader access function.

Only one active connection is allowed per context. If a second connection is required, a different context needs to be established and supplied to SCardConnect.

Requirements

Runs on Versions Defined in Include Link to
Windows CE OS 3.0 and later Winscard.h   Winscard.lib

Note   This API is part of the complete Windows CE OS package as provided by Microsoft. The functionality of a particular platform is determined by the original equipment manufacturer (OEM) and some devices may not support this API.

See Also

SCardControl, SCardDisconnect, SCardEstablishContext, SCardReconnect

 Last updated on Tuesday, July 13, 2004

© 1992-2000 Microsoft Corporation. All rights reserved.