Beispiel #1
0
 public static void ConnectToReader(ISmartCardReader smartCardReader)
 {
     try
     {
         ReaderState state = ContextHandler.Instance.GetReaderState(smartCardReader.PcscReaderName, ReaderStates.Unaware);
         if (state.AtrLength > 0)
         {
             smartCardReader.Connect(ReaderSharingMode.Shared, Protocol.Any);
         }
         else
         {
             smartCardReader.ConnectDirect();
         }
     }
     catch (Win32Exception e)
     {
         throw new Exception($"Unable to connect with {smartCardReader.PcscReaderName}\n{e.Message}");
     }
 }