예제 #1
0
        public int Reader_SendCommand(ref string strCmd, ref string strRes, ref string strSW)
        {
            byte[] array = new byte[600];
            int    num   = 0;

            byte[] bytes = Encoding.Default.GetBytes(strCmd);
            int    lens  = int.Parse((strCmd.Length / 2).ToString());
            int    num2  = PCSC.PCSC_SendCommand(bytes, lens, array, ref num);
            int    num3  = num;
            short  num4  = 0;

            while ((int)num4 < num3 * 2)
            {
                strRes += (char)array[(int)num4];
                num4   += 1;
            }
            strSW = num2.ToString("X");
            strSW = strSW.ToUpper();
            int result;

            if (num2 < 0)
            {
                result = num2;
            }
            else
            {
                result = 0;
            }
            return(result);
        }
예제 #2
0
        public int Reader_SendCommand(ref string strCmd, ref string strRes, ref string strSW)
        {
            byte[] TstrRes    = new byte[600];
            int    TlngReslen = 0;

            byte[] Tcomm     = Encoding.Default.GetBytes(strCmd);
            int    Lens      = int.Parse((strCmd.Length / 2).ToString());
            int    retval    = PCSC.PCSC_SendCommand(Tcomm, Lens, TstrRes, ref TlngReslen);
            int    lngReslen = TlngReslen;
            short  i         = 0;

            while ((int)i < lngReslen * 2)
            {
                strRes += (char)TstrRes[(int)i];
                i      += 1;
            }
            strSW = retval.ToString("X");
            strSW = strSW.ToUpper();
            int result;

            if (retval < 0)
            {
                result = retval;
            }
            else
            {
                result = 0;
            }
            return(result);
        }
예제 #3
0
        public int Reader_CardReset(ref short intReslen, ref string strRes)
        {
            byte[] array = new byte[600];
            int    num   = PCSC.PCSC_Connect(PCSC.ReaderN);

            strRes = "";
            int result;

            if (num != 0)
            {
                result = -1;
            }
            else
            {
                try
                {
                    num = PCSC.PCSC_CardReset(array, ref intReslen);
                }
                catch (Exception var_3_3A)
                {
                    result = 0;
                    return(result);
                }
                if (num != 0)
                {
                    result = -3;
                }
                else
                {
                    strRes = Encoding.ASCII.GetString(array, 0, (int)(intReslen * 2));
                    result = 0;
                }
            }
            return(result);
        }
예제 #4
0
        public int Reader_CardReset(ref short intReslen, ref string strRes)
        {
            byte[] TstrRes = new byte[600];
            int    retval  = PCSC.PCSC_Connect(PCSC.ReaderN);

            strRes = "";
            int result;

            if (retval != 0)
            {
                result = -1;
            }
            else
            {
                try
                {
                    retval = PCSC.PCSC_CardReset(TstrRes, ref intReslen);
                }
                catch (Exception e_3A)
                {
                    result = 0;
                    return(result);
                }
                if (retval != 0)
                {
                    result = -3;
                }
                else
                {
                    strRes = Encoding.ASCII.GetString(TstrRes, 0, (int)(intReslen * 2));
                    result = 0;
                }
            }
            return(result);
        }
예제 #5
0
        public void TimeD(long lngTD)
        {
            long tickCount = PCSC.GetTickCount();
            long num;

            do
            {
                Application.DoEvents();
                if (PCSC.GetTickCount() - tickCount < 0L)
                {
                    tickCount = PCSC.GetTickCount();
                }
                num = PCSC.GetTickCount() - tickCount;
            }while (num >= lngTD);
        }
예제 #6
0
        public void TimeD(long lngTD)
        {
            long lngST = PCSC.GetTickCount();
            long lngET;

            do
            {
                Application.DoEvents();
                if (PCSC.GetTickCount() - lngST < 0L)
                {
                    lngST = PCSC.GetTickCount();
                }
                lngET = PCSC.GetTickCount() - lngST;
            }while (lngET >= lngTD);
        }
예제 #7
0
        public long Reader_OpenPort()
        {
            PCSC.PortSpeed = 115200L;
            int  num = PCSC.PCSC_Connect(PCSC.ReaderN);
            long result;

            if (num != 0)
            {
                result = -1L;
            }
            else
            {
                result = 0L;
            }
            return(result);
        }
예제 #8
0
        public long Reader_OpenPort()
        {
            PCSC.PortSpeed = 115200L;
            int retval = PCSC.PCSC_Connect(PCSC.ReaderN);
            //MessageBox.Show(PCSC.ReaderN.ToString());
            //MessageBox.Show(retval.ToString());
            long result;

            if (retval != 0)
            {
                result = -1L;
            }
            else
            {
                result = 0L;
            }
            return(result);
        }
예제 #9
0
        public long Reader_CardReset(uint hhcard, ref short intReslen, ref string strRes, string hhcardname)
        {
            byte[] array = new byte[600];
            strRes = "";
            int num = PCSC.PCSC_CardReset_Ex(hhcard, array, ref intReslen, hhcardname);

            strRes = Encoding.ASCII.GetString(array);
            long result;

            if (num != 0)
            {
                result = 1L;
            }
            else
            {
                result = (long)num;
            }
            return(result);
        }
예제 #10
0
        public long Reader_CardReset(uint hhcard, ref short intReslen, ref string strRes, string hhcardname)
        {
            byte[] atr = new byte[600];
            strRes = "";
            int retval = PCSC.PCSC_CardReset_Ex(hhcard, atr, ref intReslen, hhcardname);

            strRes = Encoding.ASCII.GetString(atr);
            long result;

            if (retval != 0)
            {
                result = 1L;
            }
            else
            {
                result = (long)retval;
            }
            return(result);
        }
예제 #11
0
        //public static extern int PCSC_Connect(int NofReaders);
        //函数调用有问题,无法使用
        public static string GetADMB(string iccid)
        {
            string str1 = "";//"700B107109197410";//8456CCAD7CBC13E3

            if (iccid.Substring(0, 4) == "8986")
            {
                iccid = Swap(iccid);
            }
            if (iccid.Length != 16)
            {
                str1 = iccid.Substring(iccid.Length - 16, 16);
            }
            //return str1;
            byte[] bytes = new byte[60];
            long   lng   = PCSC.GetSupperAdmin(str1, bytes);
            string admb  = Encoding.Default.GetString(bytes);

            //foreach (byte b in bytes)
            //{
            //    str2 += b;
            //}
            return(admb);
        }
예제 #12
0
 public void Reader_ClosePort()
 {
     PCSC.PCSC_Close();
 }
예제 #13
0
 public long PCSCListOfReader(StringBuilder Readers)
 {
     return(PCSC.PCSCListReader(Readers));
 }