コード例 #1
0
ファイル: SCardReader.cs プロジェクト: uheqiang/p2abcengine
        public SCardError Status(out string[] ReaderName,
                                 out SCardState State,
                                 out SCardProtocol Protocol,
                                 out byte[] Atr)
        {
            SCardError rc;
            IntPtr     dwState    = IntPtr.Zero;
            IntPtr     dwProtocol = IntPtr.Zero;

            rc = SCardAPI.Lib.Status(cardHandle,
                                     out ReaderName,
                                     out dwState,
                                     out dwProtocol,
                                     out Atr);

            if (rc == SCardError.Success)
            {
                Protocol = SCardHelper.ToProto(dwProtocol);
                State    = SCardHelper.ToState(dwState);

                // update local copies
                activeprot = Protocol;
                if (ReaderName.Length >= 1)
                {
                    readername = ReaderName[0];
                }
            }
            else
            {
                Protocol = SCardProtocol.Unset;
                State    = SCardState.Unknown;
            }

            return(rc);
        }
コード例 #2
0
        /// <inheritdoc />
        public SCardError Status(out string[] readerName, out SCardState state, out SCardProtocol protocol,
                                 out byte[] atr)
        {
            var rc = Platform.Lib.Status(
                _cardHandle,
                out readerName,
                out var dwState,
                out var dwProtocol,
                out atr);

            if (rc == SCardError.Success)
            {
                protocol = SCardHelper.ToProto(dwProtocol);
                state    = SCardHelper.ToState(dwState);

                // update local copies
                ActiveProtocol = protocol;
                if (readerName.Length >= 1)
                {
                    ReaderName = readerName[0];
                }
            }
            else
            {
                protocol = SCardProtocol.Unset;
                state    = SCardState.Unknown;
            }

            return(rc);
        }
コード例 #3
0
        /// <inheritdoc />
        public ReaderStatus GetStatus()
        {
            var handle = CardHandle.Handle;

            _api.Status(
                hCard: handle,
                szReaderName: out var readerNames,
                pdwState: out var dwState,
                pdwProtocol: out var dwProtocol,
                pbAtr: out var atr)
            .ThrowIfNotSuccess();

            return(new ReaderStatus(
                       readerNames: readerNames,
                       state: SCardHelper.ToState(dwState),
                       protocol: SCardHelper.ToProto(dwProtocol),
                       atr: atr));
        }