Partager via


SCardConnect (Windows Embedded CE 6.0)

1/6/2010

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.

Syntax

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

Parameters

  • hContext
    [in] Handle that identifies the resource manager context. The resource manager context is set by a previous call to SCardEstablishContext.
  • szReader
    [in] Null-terminated string that specifies the name of the reader containing the target card.
  • dwShareMode
    [in] Specifies a flag that indicates whether other applications can form connections to the card. The following table shows the possible values for dwShareMode.

    Value Description

    SCARD_SHARE_EXCLUSIVE

    This application is not willing to share the card with other applications.

  • dwPreferredProtocols
    [in] Specifies a bit mask of acceptable protocols for the connection. The following table 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.

  • phCard
    [out] Pointer to a handle that identifies the connection to the smart card in the designated reader.
  • pdwActiveProtocol
    [out] Pointer to a DWORD that receives a flag indicating the established active protocol. The following table 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

    It is possible that there is no card in the reader.

Return Value

The following table shows the possible return values.

Value Description

SCARD_S_SUCCESS

Succeeds

An error value (see Smart Card Error Values for a list of all error values).

Fails

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

Header winscard.h
Library winscard.lib
Windows Embedded CE Windows CE 3.0 and later

See Also

Reference

Smart Card Functions
SCardControl
SCardDisconnect
SCardEstablishContext
SCardReconnect