Type a page name and press Enter. You'll jump to the page if it exists, or you can create it if it doesn't.
To create a page in a module other than winscard, prefix the name with the module name and a period.
SCardGetStatusChange (winscard)
.
C# Signature:
/// <summary>
/// The SCardGetStatusChange function blocks execution until the current availability of the cards in a specific set of readers changes.
/// </summary>
/// <param name="hContext">A handle that identifies the resource manager context. The resource manager context is set by a previous call to the SCardEstablishContext function.</param>
/// <param name="dwTimeout">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.</param>
/// <param name="rgReaderStates">An array of SCARD_READERSTATE structures that specify the readers to watch, and that receives the result.</param>
/// <param name="cReaders">the number of elements in the rgReaderStates array.</param>
/// <returns>This function returns different values depending on whether it succeeds or fails</returns>
[DllImport("winscard.dll", CharSet=CharSet.Auto)]
static extern SCardFunctionReturnCodes SCardGetStatusChange(int hContext, int dwTimeout, [In, Out] SCARD_READERSTATE[] rgReaderStates, int cReaders);
static extern int SCardGetStatusChange(int hContext, int dwTimeout, [In, Out] SCARD_READERSTATE[] rgReaderStates, int cReaders);
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;
Tips & Tricks:
Please add some!
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;
}
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;
Alternative Managed API:
TODO
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
The SCardGetStatusChange function blocks execution until the current availability of the cards in a specific set of readers changes.
12/18/2012 1:16:42 PM - -173.167.132.185
Please edit this page!
Do you have...
helpful tips or sample code to share for using this API in managed code?
corrections to the existing content?
variations of the signature you want to share?
additional languages you want to include?
Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).