SCardEndTransaction function (winscard.h)

The SCardEndTransaction function completes a previously declared transaction, allowing other applications to resume interactions with the card.

Syntax

LONG SCardEndTransaction(
  [in] SCARDHANDLE hCard,
  [in] DWORD       dwDisposition
);

Parameters

[in] hCard

Reference value obtained from a previous call to SCardConnect. This value would also have been used in an earlier call to SCardBeginTransaction.

[in] dwDisposition

Action to take on the card in the connected reader on close.

Value Meaning
SCARD_EJECT_CARD
Eject the card.
SCARD_LEAVE_CARD
Do not do anything special.
SCARD_RESET_CARD
Reset the card.
SCARD_UNPOWER_CARD
Power down the card.

Return value

If the function succeeds, the function returns SCARD_S_SUCCESS.

If the function fails, it returns an error code. For more information, see Smart Card Return Values. Possible error codes follow.

Return code/value Description
SCARD_W_RESET_CARD
0x80100068L
The transaction was released. Any future communication with the card requires a call to the SCardReconnect function.

Windows Server 2008, Windows Vista, Windows Server 2003 and Windows XP:  The transaction was not released. The application must immediately call the SCardDisconnect, SCardReconnect, or SCardReleaseContext function to avoid an existing transaction blocking other threads and processes from communicating with the smart card.

Remarks

The SCardEndTransaction function is a smart card and reader access function. For more information on other access functions, see Smart Card and Reader Access Functions.

Examples

The following example ends a smart card transaction. The example assumes that lReturn is a valid variable of type LONG, that hCard is a valid handle received from a previous call to the SCardConnect function, and that hCard was passed to a previous call to the SCardBeginTransaction function.


lReturn = SCardEndTransaction(hCard, 
                              SCARD_LEAVE_CARD);
if ( SCARD_S_SUCCESS != lReturn )
    printf("Failed SCardEndTransaction\n");

Requirements

Requirement Value
Minimum supported client Windows XP [desktop apps only]
Minimum supported server Windows Server 2003 [desktop apps only]
Target Platform Windows
Header winscard.h
Library Winscard.lib
DLL Winscard.dll

See also

SCardBeginTransaction

SCardConnect