예제 #1
0
        /**m* SCardChannel/Reconnect
         *
         * NAME
         *   SCardChannel.Reconnect()
         *
         * SYNOPSIS
         *   bool Reconnect()
         *   bool Reconnect(uint disposition)
         *
         * DESCRIPTION
         *   Re-open the connection channel to the smartcard
         *
         * INPUTS
         *   The disposition parameter must take one of the following values:
         *   - SCARD.EJECT_CARD
         *   - SCARD.UNPOWER_CARD
         *   - SCARD.RESET_CARD
         *   - SCARD.LEAVE_CARD
         *   If this parameter is omitted, it defaults to SCARD.RESET_CARD
         *
         * OUTPUT
         *   Returns true if the connection has been successfully re-established.
         *   Returns false if not. See LastError for details.
         *
         * SEE ALSO
         *   SCardChannel.Connect
         *   SCardChannel.Disconnect
         *
         **/

        public virtual bool Reconnect(uint disposition)
        {
            uint rc;

            if (!Connected)
            {
                return(false);
            }

            rc =
                SCARD.Reconnect(_hCard, _share_mode, _want_protocols, disposition, ref _active_protocol);
            if (rc != SCARD.S_SUCCESS)
            {
                _hCard      = IntPtr.Zero;
                _last_error = rc;
                return(false);
            }

            UpdateState();
            return(true);
        }