コード例 #1
0
        private static void StartTransaction()
        {
            Array.Clear(SendBuff, 0, 262);
            Array.Clear(RecvBuff, 0, 262);

            //Prepare Buffer
            SendBuff[0] = 0xFF; //start
            SendBuff[2] = 0x20; //memory adres
            SendBuff[3] = 0x0;
            SendBuff[4] = 0x01;
            SendBuff[5] = 0x1;//I2c
            sendLen     = 6;
            RecvLen     = RecvBuff.Length;

            ioRequest.dwProtocol  = Protocol;
            ioRequest.cbPciLength = 8;

            retCode = ModWinsCard.SCardBeginTransaction(hCard);
            if (retCode != ModWinsCard.SCARD_S_SUCCESS)
            {
                throw new Exception(retCode.ToString());
            }

            retCode = ModWinsCard.SCardTransmit(hCard, ref ioRequest, ref SendBuff[0], sendLen, ref ioRequest, ref RecvBuff[0], ref RecvLen);
            if (retCode != ModWinsCard.SCARD_S_SUCCESS)
            {
                throw new Exception(retCode.ToString());
            }
        }