Example #1
0
        private void button2_Click(object sender, EventArgs e)
        {
            Int32         result;
            String        imagePath;
            StringBuilder errorText = new StringBuilder(maxErrorTextLen);

            if (image != null)
            {
                image.Dispose();
                image = null;
            }
            imagePath = Path.GetTempPath() + "image.bmp";
            //当程序打开设备后,可以多次调用读取信息函数。
            result          = Card2.GetPersonMsgW(ref person, imagePath);
            textResult.Text = Convert.ToString(result);
            Card2.GetErrorTextW(errorText, maxErrorTextLen);
            textDescription.Text = errorText.ToString();

            if (0 == result)
            {
                birthday   = ConvertDate(person.birthday, 1);
                validDate  = ConvertDate(person.validStart, 2) + "-";
                validDate += ConvertDate(person.validEnd, 2);
                image      = new Bitmap(imagePath);
            }
            else
            {
                birthday  = "";
                validDate = "";
            }
            Invalidate();
        }
Example #2
0
        private void button3_Click(object sender, EventArgs e)
        {
            Int32         result;
            StringBuilder errorText = new StringBuilder(maxErrorTextLen);

            //读完卡后,必须关闭设备。
            result          = Card2.CloseCardReader();
            textResult.Text = Convert.ToString(result);
            Card2.GetErrorTextW(errorText, maxErrorTextLen);
            textDescription.Text = errorText.ToString();
        }
Example #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            Int32         result;
            StringBuilder errorText = new StringBuilder(maxErrorTextLen);

            /*参数1为端口号。1表示串口1,2表示串口2,依次类推。1001表示USB。0表示自动选择。
             * 参数2为标志位。0x02表示启用重复读卡。0x04表示读卡后接着读取新地址。
             * 各个数值可以用“按位或”运算符组合起来。
             * 参数3为波特率。使用串口阅读器的程序应正确设置此参数。出厂机器的波特率一般为115200。
             */
            result          = Card2.OpenCardReader(0, 2, 115200);
            textResult.Text = Convert.ToString(result);
            Card2.GetErrorTextW(errorText, maxErrorTextLen);
            textDescription.Text = errorText.ToString();
        }