SCardEndTransaction function (winscard.h)

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


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


[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
Eject the card.
Do not do anything special.
Reset the 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
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.


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.


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, 
if ( SCARD_S_SUCCESS != lReturn )
    printf("Failed SCardEndTransaction\n");


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