SCardControl function (winscard.h)

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(
  [in]  SCARDHANDLE hCard,
  [in]  DWORD       dwControlCode,
  [in]  LPCVOID     lpInBuffer,
  [in]  DWORD       cbInBufferSize,
  [out] LPVOID      lpOutBuffer,
  [in]  DWORD       cbOutBufferSize,
  [out] LPDWORD     lpBytesReturned
);

Parameters

[in] hCard

Reference value returned from SCardConnect.

[in] dwControlCode

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

[in] 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.

[in] cbInBufferSize

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

[out] 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.

[in] cbOutBufferSize

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

[out] 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

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

SCardDisconnect