SCardControl function

The SCardControl function gives you direct control of the reader. You can call it any time after a successful call to SCardConnect and before a successful call to SCardDisconnect. The effect on the state of the reader depends on the control code.

Syntax

LONG SCardControl(
  SCARDHANDLE hCard,
  DWORD       dwControlCode,
  LPCVOID     lpInBuffer,
  DWORD       cbInBufferSize,
  LPVOID      lpOutBuffer,
  DWORD       cbOutBufferSize,
  LPDWORD     lpBytesReturned
);

Parameters

hCard

Reference value returned from SCardConnect.

dwControlCode

Control code for the operation. This value identifies the specific operation to be performed.

lpInBuffer

Pointer to a buffer that contains the data required to perform the operation. This parameter can be NULL if the dwControlCode parameter specifies an operation that does not require input data.

cbInBufferSize

Size, in bytes, of the buffer pointed to by lpInBuffer.

lpOutBuffer

Pointer to a buffer that receives the operation's output data. This parameter can be NULL if the dwControlCode parameter specifies an operation that does not produce output data.

cbOutBufferSize

Size, in bytes, of the buffer pointed to by lpOutBuffer.

lpBytesReturned

Pointer to a DWORD that receives the size, in bytes, of the data stored into the buffer pointed to by lpOutBuffer.

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

The SCardControl function is a direct card access function. For more information on other direct access functions, see Direct Card Access Functions.

Examples

The following example issues a control code. The example assumes that hCardHandle is a valid handle received from a previous call to SCardConnect and that dwControlCode is a variable of type DWORD previously initialized to a valid control code. This particular control code requires no input data and expects no output data.


lReturn = SCardControl( hCardHandle,
                        dwControlCode,
                        NULL,
                        0,
                        NULL,
                        0,
                        0 );
if ( SCARD_S_SUCCESS != lReturn )
    printf("Failed SCardControl\n");

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

SCardDisconnect