Ejemplo n.º 1
0
        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);
            }
        }
Ejemplo n.º 2
0
        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, 0 /*msec*/, readerStateArray, readerStateArray.Length);

            if (ret != NfcConstant.SCARD_S_SUCCESS)
            {
                throw new ApplicationException("リーダーの初期状態の取得に失敗。code = " + ret);
            }

            return(readerStateArray);
        }