Beispiel #1
0
        /// <summary>
        /// Receive and print ATR string attribute
        /// </summary>
        /// <param name="reader">Connected smartcard reader instance</param>
        private static void DisplayCardAtr(ISCardReader reader)
        {
            byte[] atr;
            var    rc = reader.GetAttrib(SCardAttribute.AtrString, out atr);

            if (rc != SCardError.Success)
            {
                // ATR not supported?
                Console.WriteLine("Error by trying to receive the ATR. {0}\n", SCardHelper.StringifyError(rc));
            }
            else
            {
                Console.WriteLine("ATR: {0}\n", BitConverter.ToString(atr ?? new byte[] {}));
            }
        }
Beispiel #2
0
        // Funkcja wyświetlająca ATR karty znajdującej się w czytniku
        private void DisplayCardAtr(ISCardReader reader)
        {
            byte[] atr;
            // Pobranie ATR
            var rc = reader.GetAttrib(SCardAttribute.AtrString, out atr);

            // W przypadku niepowodzenia
            if (rc != SCardError.Success)
            {
                textBoxATREquals.Text = "Nie udało się połączyć. " + SCardHelper.StringifyError(rc);
            }
            else
            {
                textBoxATREquals.Text = BitConverter.ToString(atr ?? new byte[] { });
            }
        }
Beispiel #3
0
        static void DisplayCardAtr(ISCardReader reader)
        {
            try
            {
                var rc = reader.GetAttrib(SCardAttribute.AtrString, out var atr);

                if (rc != SCardError.Success)
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.Write("Error by trying to receive the ATR. {0}", SCardHelper.StringifyError(rc));
                }
                else
                {
                    Console.ForegroundColor = ConsoleColor.Gray;
                    Console.Write("{0}", BitConverter.ToString(atr ?? new byte[] { }));
                }
            }
            catch (Exception ex) { var c = Console.ForegroundColor; Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine($"\n{ex}\n"); Console.ForegroundColor = c; }
        }