Exemplo n.º 1
0
 /// <summary>
 /// ライブラリの初期化
 /// </summary>
 public void InitializeLibrary()
 {
     //RC-S380以降
     if (WinSCard.EstablishContext(ref rwContext))
     {
         readerName = WinSCard.ListReaders(rwContext);
         if (readerName != null)
         {
             Regex ver = new Regex("PaSoRi\\s+([0-9]+(\\.[0-9]+)*)", RegexOptions.IgnoreCase);
             Match m   = ver.Match(readerName);
             if (m.Success)
             {
                 String verStr = m.Groups[1].Value;
                 if (float.Parse(verStr) >= 3.0f)
                 {
                     cmd     = new byte[BUFFER_LENGTH];
                     res     = new byte[BUFFER_LENGTH];
                     authKey = null;
                     Debug.WriteLine("PcscReader Initialize OK!");
                     return;
                 }
             }
         }
     }
     Debug.WriteLine("PcscReader Error!");
     DisposeLibrary();
     throw new PcscException(WinSCardError.SCARD_E_NOT_READY, null);
 }
Exemplo n.º 2
0
        /// <summary>
        /// Pasori PC/SCの利用可否
        /// </summary>
        /// <returns>T:利用可能</returns>
        public static bool CheckPcsc()
        {
            //RC-S380以降
            IntPtr context = IntPtr.Zero;

            if (WinSCard.EstablishContext(ref context))
            {
                String readerName = WinSCard.ListReaders(context);
                WinSCard.ReleaseContext(context);

                if (readerName != null)
                {
                    Regex ver = new Regex("PaSoRi\\s+([0-9]+(\\.[0-9]+)*)", RegexOptions.IgnoreCase);
                    Match m   = ver.Match(readerName);
                    if (m.Success)
                    {
                        String verStr = m.Groups[1].Value;
                        if (float.Parse(verStr) >= 3.0f)
                        {
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }