Subsections

SCardControl

Synopsis:

#include <winscard.h>

LONG SCardControl(SCARDHANDLE hCard,
    DWORD dwControlCode,
    LPCVOID pbSendBuffer,
    DWORD cbSendLength,
    LPVOID pbRecvBuffer,
    DWORD pcbRecvLength,
    LPDWORD lpBytesReturned);

Parameters:

hCard IN Connection made from SCardConnect
dwControlCode IN Control code for the operation
pbSendBuffer IN Command to send to the reader
cbSendLength IN Length of the command
pbRecvBuffer OUT Response from the reader
pcbRecvLength IN Length of the response buffer
lpBytesReturned OUT Length of the response

Description:

This function sends a command directly to the IFD Handler to be processed by the reader. This is useful for creating client side reader drivers for functions like PIN pads, biometrics, or other extensions to the normal smart card reader that are not normally handled by PC/SC.

Note: the API of this function changed. In pcsc-lite 1.2.0 and before the API was not Windows PC/SC compatible. This has been corrected.

see § [*] for a list of supported commands by some drivers.

Example:

LONG rv;
SCARDCONTEXT hContext;
SCARDHANDLE hCard;
DWORD dwActiveProtocol, dwSendLength, dwRecvLength;
BYTE pbRecvBuffer[10];
BYTE pbSendBuffer[] = { 0x06, 0x00, 0x0A, 0x01, 0x01, 0x10 0x00 };

rv = SCardEstablishContext(SCARD_SCOPE_SYSTEM, NULL, NULL, &hContext);
rv = SCardConnect(hContext, "Reader X", SCARD_SHARE_SHARED,
         SCARD_PROTOCOL_RAW &hCard, &dwActiveProtocol);
dwSendLength = sizeof(pbSendBuffer);
dwRecvLength = sizeof(pbRecvBuffer);
rv = SCardControl(hCard, 0x42000001, pbSendBuffer, dwSendLength,
         pbRecvBuffer, sizeof(pbRecvBuffer), &dwRecvLength);

Returns:

SCARD_S_SUCCESS Successful
SCARD_E_NOT_TRANSACTED Data exchange not successful
SCARD_E_INVALID_HANDLE Invalid hCard handle
SCARD_E_INVALID_VALUE Invalid value was presented
SCARD_E_READER_UNAVAILABLE The reader has been removed
SCARD_W_RESET_CARD The card has been reset by another application
SCARD_W_REMOVED_CARD The card has been removed from the reader

2007-06-17