SCardDisconnect function

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

Syntax

LONG SCardDisconnect(
  SCARDHANDLE hCard,
  DWORD       dwDisposition
);

Parameters

hCard

Reference value obtained from a previous call to SCardConnect.

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.

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

Requirements

   
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