#include <winscard.h>
LONG SCardStatus(SCARDHANDLE hCard,
LPSTR szReaderName,
LPDWORD pcchReaderLen,
LPDWORD pdwState,
LPDWORD pdwProtocol,
LPBYTE pbAtr,
LPDWORD pcbAtrLen);
| hCard | IN | Connection made from SCardConnect |
| szReaderName | INOUT | Friendly name of this reader |
| pcchReaderLen | INOUT | Size of the szReaderName multistring |
| pdwState | OUT | Current state of this reader |
| pdwProtocol | OUT | Current protocol of this reader |
| pbAtr | OUT | Current ATR of a card in this reader |
| pcbAtrLen | OUT | Length of ATR |
This function returns the current status of the reader connected to by hCard. It's friendly name will be stored in szReaderName. pcchReaderLen will be the size of the allocated buffer for szReaderName, while pcbAtrLen will be the size of the allocated buffer for pbAtr. If either of these is too small, the function will return with SCARD_E_INSUFFICIENT_BUFFER and the necessary size in pcchReaderLen and pcbAtrLen. The current state, and protocol will be stored in pdwState and pdwProtocol respectively. pdwState is a DWORD possibly OR'd with the following values:
| Value of pdwState | Meaning |
| SCARD_ABSENT | There is no card in the reader |
| SCARD_PRESENT | There is a card in the reader, but it has not been moved into position for use |
| SCARD_SWALLOWED | There is a card in the reader in position for use. The card is not powered |
| SCARD_POWERED | Power is being provided to the card, but the reader driver is unaware of the mode of the card |
| SCARD_NEGOTIABLE | The card has been reset and is awaiting PTS negotiation |
| SCARD_SPECIFIC | The card has been reset and specific communication protocols have been established |
| Value of pdwProtocol | Meaning |
| SCARD_PROTOCOL_T0 | Use the T=0 protocol |
| SCARD_PROTOCOL_T1 | Use the T=1 protocol |
SCARDCONTEXT hContext;
SCARDHANDLE hCard;
DWORD dwActiveProtocol;
DWORD dwState, dwProtocol, dwAtrLen, dwReaderLen;
BYTE pbAtr[MAX_ATR_SIZE];
rv = SCardEstablishContext(SCARD_SCOPE_SYSTEM, NULL, NULL, &hContext);
rv = SCardConnect(hContext, "Reader X", SCARD_SHARE_SHARED,
SCARD_PROTOCOL_T0, &hCard, &dwActiveProtocol);
dwAtrLen = sizeof(pbAtr);
rv=SCardStatus(hCard, NULL, &dwReaderLen, &dwState, &dwProtocol,
pbAtr, &dwAtrLen);
| SCARD_S_SUCCESS | Successful |
| SCARD_E_INVALID_HANDLE | Invalid hCard handle |
| SCARD_E_INSUFFICIENT_BUFFER | Not enough allocated memory for szReaderName |
| or for pbAtr | |
| SCARD_E_READER_UNAVAILABLE | The reader has been removed |
2007-06-17