public static void waitReaderStatusChange(IntPtr hContext, NfcApi.SCARD_READERSTATE[] readerStateArray, int timeoutMillis) { uint ret = NfcApi.SCardGetStatusChange(hContext, timeoutMillis /*msec*/, readerStateArray, readerStateArray.Length); switch (ret) { case NfcConstant.SCARD_S_SUCCESS: break; case NfcConstant.SCARD_E_TIMEOUT: throw new TimeoutException(); default: throw new ApplicationException("リーダーの状態変化の取得に失敗。code = " + ret); } }
public static NfcApi.SCARD_READERSTATE[] initializeReaderState(IntPtr hContext, List <string> readerNameList) { NfcApi.SCARD_READERSTATE[] readerStateArray = new NfcApi.SCARD_READERSTATE[readerNameList.Count]; int i = 0; foreach (string readerName in readerNameList) { readerStateArray[i].dwCurrentState = NfcConstant.SCARD_STATE_UNAWARE; readerStateArray[i].szReader = readerName; i++; } uint ret = NfcApi.SCardGetStatusChange(hContext, 100 /*msec*/, readerStateArray, readerStateArray.Length); if (ret != NfcConstant.SCARD_S_SUCCESS) { throw new ApplicationException("リーダーの初期状態の取得に失敗。code = " + ret); } return(readerStateArray); }