SCardDisconnect function (winscard.h)

The SCardDisconnect function terminates a connection previously opened between the calling application and a smart card in the target reader.

Syntax

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

Parameters

[in] hCard

Reference value obtained from a previous call to SCardConnect.

[in] dwDisposition

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

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

Return value

This function returns different values depending on whether it succeeds or fails.

Return code Description
Success
SCARD_S_SUCCESS.
Failure
An error code. For more information, see Smart Card Return Values.

Remarks

If an application (which previously called SCardConnect) exits without calling SCardDisconnect, the card is automatically reset.

The SCardDisconnect 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 terminates the specified smart card connection. The example assumes that lReturn is a variable of type LONG, and that hCardHandle is a valid handle received from a previous call to SCardConnect.


lReturn = SCardDisconnect(hCardHandle, 
                          SCARD_LEAVE_CARD);
if ( SCARD_S_SUCCESS != lReturn )
{
    printf("Failed SCardDisconnect\n");
    exit(1);  // Or other appropriate action.
}

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

SCardConnect

SCardReconnect