/**m* SCardChannel/Connect * * NAME * SCardChannel.Connect() * * SYNOPSIS * bool Connect() * * DESCRIPTION * Open the connection channel to the smartcard (according to the specified Protocol, default is either T=0 or T=1) * * OUTPUT * Returns true if the connection has been successfully established. * Returns false if not. See LastError for details. * * SEE ALSO * SCardChannel.CardPresent * SCardChannel.CardAtr * SCardChannel.Protocol * SCardChannel.Transmit * **/ public virtual bool Connect() { uint rc; if (Connected) { return(false); } Trace.WriteLine("Connect to '" + _reader_name + "', share=" + _share_mode + ", protocol=" + _want_protocols); rc = SCARD.Connect(_hContext, _reader_name, _share_mode, _want_protocols, ref _hCard, ref _active_protocol); if (rc != SCARD.S_SUCCESS) { Trace.WriteLine(String.Format("Connect error {0:X08} ({0})", rc)); _hCard = IntPtr.Zero; _last_error = rc; return(false); } UpdateState(); return(true); }