SCardGetStatusChange function

The SCardGetStatusChange function blocks execution until the current availability of the cards in a specific set of readers changes.

The caller supplies a list of readers to be monitored by an SCARD_READERSTATE array and the maximum amount of time (in milliseconds) that it is willing to wait for an action to occur on one of the listed readers. Note that SCardGetStatusChange uses the user-supplied value in the dwCurrentState members of the rgReaderStates SCARD_READERSTATE array as the definition of the current state of the readers. The function returns when there is a change in availability, having filled in the dwEventState members of rgReaderStates appropriately.

Syntax


LONG WINAPI SCardGetStatusChange(
  _In_    SCARDCONTEXT        hContext,
  _In_    DWORD               dwTimeout,
  _Inout_ LPSCARD_READERSTATE rgReaderStates,
  _In_    DWORD               cReaders
);

Parameters

hContext [in]

A handle that identifies the resource manager context. The resource manager context is set by a previous call to the SCardEstablishContext function.

dwTimeout [in]

The maximum amount of time, in milliseconds, to wait for an action. A value of zero causes the function to return immediately. A value of INFINITE causes this function never to time out.

rgReaderStates [in, out]

An array of SCARD_READERSTATE structures that specify the readers to watch, and that receives the result.

To be notified of the arrival of a new smart card reader, set the szReader member of a SCARD_READERSTATE structure to "\\\\?PnP?\\Notification", and set all of the other members of that structure to zero.

Important  Each member of each structure in this array must be initialized to zero and then set to specific values as necessary. If this is not done, the function will fail in situations that involve remote card readers.
 
cReaders [in]

The number of elements in the rgReaderStates array.

Return value

This function returns different values depending on whether it succeeds or fails.

Return codeDescription
Success

SCARD_S_SUCCESS.

Failure

An error code. For more information, see Smart Card Return Values.

 

Remarks

The SCardGetStatusChange function is a smart card tracking function. For more information about other tracking functions, see Smart Card Tracking Functions.

Examples

For information about how to call this function, see the example in SCardLocateCards.

Requirements

Minimum supported client

Windows XP [desktop apps only]

Minimum supported server

Windows Server 2003 [desktop apps only]

Header

Winscard.h

Library

Winscard.lib

DLL

Winscard.dll

Unicode and ANSI names

SCardGetStatusChangeW (Unicode) and SCardGetStatusChangeA (ANSI)

See also

SCardCancel
SCardEstablishContext
SCardLocateCards
SCARD_READERSTATE

 

 

Show: