예제 #1
0
        public IDCardData Read()
        {
            byte[] pucIIN = new byte[4];
            byte[] pucSN  = new byte[8];
            if (!connected)
            {
                Connect();
            }
            IDCardData CardMsg = new IDCardData();

            try {
                int nRet = readCardAPI.Syn_OpenPort(iPort);
                if (nRet == 0)
                {
                    nRet = readCardAPI.Syn_GetSAMStatus(iPort, 0);
                    nRet = readCardAPI.Syn_StartFindIDCard(iPort, ref pucIIN[0], 0);
                    nRet = readCardAPI.Syn_SelectIDCard(iPort, ref pucSN[0], 0);
                    if (readCardAPI.Syn_ReadMsg(iPort, 0, ref CardMsg) == 0)
                    {
                        return(CardMsg);
                    }
                    else
                    {
                        throw new Exception("读二代证信息错误");
                    }
                }
                else
                {
                    throw new Exception("打开端口错误");
                }
            } catch {
                connected = false;
                throw;
            } finally {
                readCardAPI.Syn_ClosePort(iPort);
            }
        }
예제 #2
0
 public static extern int Syn_ReadMsg(int iPortID, int iIfOpen, ref IDCardData pIDCardData);