SCardGetStatusChange (winscard)
Last changed: -173.167.132.185

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

C# Signature:

[DllImport("winscard.dll", CharSet=CharSet.Auto)]
static extern int SCardGetStatusChange(int hContext, int dwTimeout, [In, Out] SCARD_READERSTATE[] rgReaderStates, int cReaders);

User-Defined Types:

None.

Notes:

None.

Tips & Tricks:

Please add some!

Sample Code:

private const int SCARD_STATE_UNAWARE = 0x00000000;

// get ATR of card
// hContext - previously established context
// reader - ATR will be read from card in this reader
private static byte[] atr(int hContext, string reader)
{
  int ret;
  byte[] atr = null;
  SCARD_READERSTATE[] rs = new SCARD_READERSTATE[1];
  rs[0].szReader = reader;
  rs[0].dwCurrentState = SCARD_STATE_UNAWARE;

  ret = SCardGetStatusChange(hContext, 100, rs, 1);
  if (ret == 0 && rs[0].cbAtr > 0 && rs[0].rgbAtr != null)
  {
   atr = new byte[rs[0].cbAtr];
   Array.Copy(rs[0].rgbAtr, atr, rs[0].cbAtr);
  }
  return atr;
}

Alternative Managed API:

TODO

Documentation