예제 #1
0
        public string SendAPDU(string sAPDU)
        {
            SCARD_IO_REQUEST sendRequest;

            sendRequest.dwProtocol  = (int)activeProtocol;
            sendRequest.cbPciLength = 8;

            SCARD_IO_REQUEST receiveRequest;

            receiveRequest.cbPciLength = 8;
            receiveRequest.dwProtocol  = (int)activeProtocol;

            byte[] abAPDU   = new byte[300];
            byte[] abResp   = new byte[300];
            UInt32 wLenSend = 0;
            Int32  wLenRecv = 260;

            sAPDU    = Utility.RemoveNonHexa(sAPDU);
            wLenSend = Utility.StrByteArrayToByteArray(sAPDU, ref abAPDU);

            LastError = WinSCard.SCardTransmit(
                _cardHandle,
                ref sendRequest,
                abAPDU,
                (int)wLenSend,
                ref receiveRequest,
                abResp,
                ref wLenRecv);

            if (!IsSuccess(LastError))
            {
                return(String.Empty);
            }

            return(Utility.ByteArrayToStrByteArray(
                       abResp,
                       (UInt16)wLenRecv));
        }