在线观看www成人影院-在线观看www日本免费网站-在线观看www视频-在线观看操-欧美18在线-欧美1级

0
  • 聊天消息
  • 系統消息
  • 評論與回復
登錄后你可以
  • 下載海量資料
  • 學習在線課程
  • 觀看技術視頻
  • 寫文章/發帖/加入社區
會員中心
創作中心

完善資料讓更多小伙伴認識你,還能領取20積分哦,立即完善>

3天內不再提示

USB免驅全協議IC卡讀寫器C#小程序開發

鄒振豪 ? 來源:jf_51178285 ? 作者:jf_51178285 ? 2025-01-02 14:05 ? 次閱讀

USB免驅全協議ic讀卡器:

wKgZO2d2BlqAa8jrAAGE51PHONY675.png

小程序UI界面:

wKgZO2d2BsuAF4a-AABorgKt2hg790.png

UI界面底代碼:

namespace WindowsFormsApplication1
{
    partial class Form1
    {
        /// 
        /// 必需的設計器變量。
        /// 
        private System.ComponentModel.IContainer components = null;
 
        /// 
        /// 清理所有正在使用的資源。
        /// 
        /// 如果應釋放托管資源,為 true;否則為 false。
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }
 
        #region Windows 窗體設計器生成的代碼
 
        /// 
        /// 設計器支持所需的方法 - 不要
        /// 使用代碼編輯器修改此方法的內容。
        /// 
        private void InitializeComponent()
        {
            this.components = new System.ComponentModel.Container();
            this.button1 = new System.Windows.Forms.Button();
            this.button2 = new System.Windows.Forms.Button();
            this.button3 = new System.Windows.Forms.Button();
            this.button4 = new System.Windows.Forms.Button();
            this.button5 = new System.Windows.Forms.Button();
            this.button6 = new System.Windows.Forms.Button();
            this.button7 = new System.Windows.Forms.Button();
            this.button8 = new System.Windows.Forms.Button();
            this.textBox1 = new System.Windows.Forms.TextBox();
            this.button9 = new System.Windows.Forms.Button();
            this.textBox3 = new System.Windows.Forms.TextBox();
            this.button11 = new System.Windows.Forms.Button();
            this.label1 = new System.Windows.Forms.Label();
            this.textBox4 = new System.Windows.Forms.TextBox();
            this.button12 = new System.Windows.Forms.Button();
            this.timer1 = new System.Windows.Forms.Timer(this.components);
            this.timer2 = new System.Windows.Forms.Timer(this.components);
            this.button10 = new System.Windows.Forms.Button();
            this.button13 = new System.Windows.Forms.Button();
            this.button14 = new System.Windows.Forms.Button();
            this.button15 = new System.Windows.Forms.Button();
            this.button16 = new System.Windows.Forms.Button();
            this.textBox2 = new System.Windows.Forms.TextBox();
            this.textBox5 = new System.Windows.Forms.TextBox();
            this.label2 = new System.Windows.Forms.Label();
            this.textBox7 = new System.Windows.Forms.TextBox();
            this.label3 = new System.Windows.Forms.Label();
            this.label4 = new System.Windows.Forms.Label();
            this.label5 = new System.Windows.Forms.Label();
            this.label6 = new System.Windows.Forms.Label();
            this.button17 = new System.Windows.Forms.Button();
            this.textBox6 = new System.Windows.Forms.TextBox();
            this.button18 = new System.Windows.Forms.Button();
            this.button19 = new System.Windows.Forms.Button();
            this.textBox8 = new System.Windows.Forms.TextBox();
            this.button20 = new System.Windows.Forms.Button();
            this.textBox9 = new System.Windows.Forms.TextBox();
            this.timer3 = new System.Windows.Forms.Timer(this.components);
            this.timer4 = new System.Windows.Forms.Timer(this.components);
            this.SuspendLayout();
            // 
            // button1
            // 
            this.button1.Location = new System.Drawing.Point(40, 45);
            this.button1.Name = "button1";
            this.button1.Size = new System.Drawing.Size(105, 30);
            this.button1.TabIndex = 0;
            this.button1.Text = "輕松讀卡";
            this.button1.UseVisualStyleBackColor = true;
            this.button1.Click += new System.EventHandler(this.button1_Click);
            // 
            // button2
            // 
            this.button2.Location = new System.Drawing.Point(40, 81);
            this.button2.Name = "button2";
            this.button2.Size = new System.Drawing.Size(105, 30);
            this.button2.TabIndex = 1;
            this.button2.Text = "輕松寫卡";
            this.button2.UseVisualStyleBackColor = true;
            this.button2.Click += new System.EventHandler(this.button2_Click);
            // 
            // button3
            // 
            this.button3.Location = new System.Drawing.Point(40, 350);
            this.button3.Name = "button3";
            this.button3.Size = new System.Drawing.Size(105, 30);
            this.button3.TabIndex = 2;
            this.button3.Text = "改單區密碼";
            this.button3.UseVisualStyleBackColor = true;
            this.button3.Click += new System.EventHandler(this.button3_Click);
            // 
            // button4
            // 
            this.button4.ForeColor = System.Drawing.Color.Red;
            this.button4.Location = new System.Drawing.Point(40, 7);
            this.button4.Name = "button4";
            this.button4.Size = new System.Drawing.Size(105, 30);
            this.button4.TabIndex = 3;
            this.button4.Text = "讓設備發出聲響";
            this.button4.UseVisualStyleBackColor = true;
            this.button4.Click += new System.EventHandler(this.button4_Click);
            // 
            // button5
            // 
            this.button5.ForeColor = System.Drawing.Color.Blue;
            this.button5.Location = new System.Drawing.Point(40, 120);
            this.button5.Name = "button5";
            this.button5.Size = new System.Drawing.Size(105, 30);
            this.button5.TabIndex = 4;
            this.button5.Text = "寫漢字至卡中";
            this.button5.UseVisualStyleBackColor = true;
            this.button5.Click += new System.EventHandler(this.button5_Click);
            // 
            // button6
            // 
            this.button6.ForeColor = System.Drawing.Color.Blue;
            this.button6.Location = new System.Drawing.Point(151, 120);
            this.button6.Name = "button6";
            this.button6.Size = new System.Drawing.Size(105, 30);
            this.button6.TabIndex = 5;
            this.button6.Text = "從卡中讀出漢字";
            this.button6.UseVisualStyleBackColor = true;
            this.button6.Click += new System.EventHandler(this.button6_Click);
            // 
            // button7
            // 
            this.button7.Location = new System.Drawing.Point(40, 189);
            this.button7.Name = "button7";
            this.button7.Size = new System.Drawing.Size(105, 30);
            this.button7.TabIndex = 6;
            this.button7.Text = "每十秒讀一次";
            this.button7.UseVisualStyleBackColor = true;
            this.button7.Click += new System.EventHandler(this.button7_Click);
            // 
            // button8
            // 
            this.button8.Location = new System.Drawing.Point(40, 222);
            this.button8.Name = "button8";
            this.button8.Size = new System.Drawing.Size(429, 30);
            this.button8.TabIndex = 7;
            this.button8.Text = "讀出設備全球唯一的設備編號,作為加密狗用";
            this.button8.UseVisualStyleBackColor = true;
            this.button8.Click += new System.EventHandler(this.button8_Click);
            // 
            // textBox1
            // 
            this.textBox1.ForeColor = System.Drawing.Color.Blue;
            this.textBox1.Location = new System.Drawing.Point(40, 156);
            this.textBox1.Name = "textBox1";
            this.textBox1.RightToLeft = System.Windows.Forms.RightToLeft.Yes;
            this.textBox1.Size = new System.Drawing.Size(438, 21);
            this.textBox1.TabIndex = 8;
            this.textBox1.Text = "王小明說:天下風云出我輩 一入江湖歲月催,Yes2018";
            this.textBox1.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
            // 
            // button9
            // 
            this.button9.ForeColor = System.Drawing.Color.Blue;
            this.button9.Location = new System.Drawing.Point(279, 120);
            this.button9.Name = "button9";
            this.button9.Size = new System.Drawing.Size(190, 30);
            this.button9.TabIndex = 10;
            this.button9.Text = "發送字符至帶顯示的讀卡器";
            this.button9.UseVisualStyleBackColor = true;
            this.button9.Click += new System.EventHandler(this.button9_Click);
            // 
            // textBox3
            // 
            this.textBox3.ForeColor = System.Drawing.Color.Red;
            this.textBox3.Location = new System.Drawing.Point(196, 313);
            this.textBox3.Name = "textBox3";
            this.textBox3.Size = new System.Drawing.Size(116, 21);
            this.textBox3.TabIndex = 13;
            // 
            // button11
            // 
            this.button11.ForeColor = System.Drawing.Color.Red;
            this.button11.Location = new System.Drawing.Point(40, 307);
            this.button11.Name = "button11";
            this.button11.Size = new System.Drawing.Size(105, 32);
            this.button11.TabIndex = 11;
            this.button11.Text = "只讀卡號";
            this.button11.UseVisualStyleBackColor = true;
            this.button11.Click += new System.EventHandler(this.button11_Click);
            // 
            // label1
            // 
            this.label1.AutoSize = true;
            this.label1.ForeColor = System.Drawing.Color.Red;
            this.label1.Location = new System.Drawing.Point(149, 316);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(41, 12);
            this.label1.TabIndex = 14;
            this.label1.Text = "卡號:";
            // 
            // textBox4
            // 
            this.textBox4.BackColor = System.Drawing.Color.White;
            this.textBox4.Location = new System.Drawing.Point(151, 195);
            this.textBox4.Name = "textBox4";
            this.textBox4.Size = new System.Drawing.Size(87, 21);
            this.textBox4.TabIndex = 18;
            // 
            // button12
            // 
            this.button12.ForeColor = System.Drawing.Color.Red;
            this.button12.Location = new System.Drawing.Point(364, 302);
            this.button12.Name = "button12";
            this.button12.Size = new System.Drawing.Size(105, 32);
            this.button12.TabIndex = 19;
            this.button12.Text = "輪詢讀IC卡號";
            this.button12.UseVisualStyleBackColor = true;
            this.button12.Click += new System.EventHandler(this.button12_Click);
            // 
            // timer1
            // 
            this.timer1.Interval = 20;
            this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
            // 
            // timer2
            // 
            this.timer2.Interval = 6000;
            this.timer2.Tick += new System.EventHandler(this.timer2_Tick);
            // 
            // button10
            // 
            this.button10.Location = new System.Drawing.Point(151, 350);
            this.button10.Name = "button10";
            this.button10.Size = new System.Drawing.Size(318, 30);
            this.button10.TabIndex = 20;
            this.button10.Text = "修改A、B密碼及控制字";
            this.button10.UseVisualStyleBackColor = true;
            this.button10.Click += new System.EventHandler(this.button10_Click_1);
            // 
            // button13
            // 
            this.button13.ForeColor = System.Drawing.Color.Blue;
            this.button13.Location = new System.Drawing.Point(40, 392);
            this.button13.Name = "button13";
            this.button13.Size = new System.Drawing.Size(164, 30);
            this.button13.TabIndex = 21;
            this.button13.Text = "寫設備存儲區1  4個字節";
            this.button13.UseVisualStyleBackColor = true;
            this.button13.Click += new System.EventHandler(this.button13_Click);
            // 
            // button14
            // 
            this.button14.ForeColor = System.Drawing.Color.Blue;
            this.button14.Location = new System.Drawing.Point(364, 392);
            this.button14.Name = "button14";
            this.button14.Size = new System.Drawing.Size(105, 30);
            this.button14.TabIndex = 22;
            this.button14.Text = "讀設備存儲區1";
            this.button14.UseVisualStyleBackColor = true;
            this.button14.Click += new System.EventHandler(this.button14_Click);
            // 
            // button15
            // 
            this.button15.ForeColor = System.Drawing.Color.Blue;
            this.button15.Location = new System.Drawing.Point(40, 428);
            this.button15.Name = "button15";
            this.button15.Size = new System.Drawing.Size(164, 30);
            this.button15.TabIndex = 23;
            this.button15.Text = "寫設備存儲區2  8個字節";
            this.button15.UseVisualStyleBackColor = true;
            this.button15.Click += new System.EventHandler(this.button15_Click);
            // 
            // button16
            // 
            this.button16.ForeColor = System.Drawing.Color.Blue;
            this.button16.Location = new System.Drawing.Point(364, 428);
            this.button16.Name = "button16";
            this.button16.Size = new System.Drawing.Size(105, 30);
            this.button16.TabIndex = 24;
            this.button16.Text = "讀設備存儲區2";
            this.button16.UseVisualStyleBackColor = true;
            this.button16.Click += new System.EventHandler(this.button16_Click);
            // 
            // textBox2
            // 
            this.textBox2.ForeColor = System.Drawing.Color.Blue;
            this.textBox2.Location = new System.Drawing.Point(222, 398);
            this.textBox2.Name = "textBox2";
            this.textBox2.Size = new System.Drawing.Size(57, 21);
            this.textBox2.TabIndex = 25;
            this.textBox2.Text = "01020304";
            // 
            // textBox5
            // 
            this.textBox5.ForeColor = System.Drawing.Color.Blue;
            this.textBox5.Location = new System.Drawing.Point(222, 434);
            this.textBox5.Name = "textBox5";
            this.textBox5.Size = new System.Drawing.Size(108, 21);
            this.textBox5.TabIndex = 26;
            this.textBox5.Text = "0102030405060708";
            // 
            // label2
            // 
            this.label2.AutoSize = true;
            this.label2.ForeColor = System.Drawing.Color.Blue;
            this.label2.Location = new System.Drawing.Point(292, 401);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(65, 12);
            this.label2.TabIndex = 27;
            this.label2.Text = "16進制數字";
            // 
            // textBox7
            // 
            this.textBox7.Font = new System.Drawing.Font("宋體", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            this.textBox7.Location = new System.Drawing.Point(170, 59);
            this.textBox7.Multiline = true;
            this.textBox7.Name = "textBox7";
            this.textBox7.Size = new System.Drawing.Size(230, 52);
            this.textBox7.TabIndex = 29;
            this.textBox7.Text = "000102030405060708090A0B0C0D0E0F000102030405060708090A0B0C0D0E0F00010203040506070" +
    "8090A0B0C0D0E0F";
            // 
            // label3
            // 
            this.label3.AutoSize = true;
            this.label3.Location = new System.Drawing.Point(168, 44);
            this.label3.Name = "label3";
            this.label3.Size = new System.Drawing.Size(65, 12);
            this.label3.TabIndex = 30;
            this.label3.Text = "16進制數字";
            // 
            // label4
            // 
            this.label4.AutoSize = true;
            this.label4.Location = new System.Drawing.Point(406, 62);
            this.label4.Name = "label4";
            this.label4.Size = new System.Drawing.Size(47, 12);
            this.label4.TabIndex = 31;
            this.label4.Text = "第 0 塊";
            // 
            // label5
            // 
            this.label5.AutoSize = true;
            this.label5.Location = new System.Drawing.Point(406, 77);
            this.label5.Name = "label5";
            this.label5.Size = new System.Drawing.Size(47, 12);
            this.label5.TabIndex = 32;
            this.label5.Text = "第 1 塊";
            // 
            // label6
            // 
            this.label6.AutoSize = true;
            this.label6.Location = new System.Drawing.Point(406, 93);
            this.label6.Name = "label6";
            this.label6.Size = new System.Drawing.Size(47, 12);
            this.label6.TabIndex = 33;
            this.label6.Text = "第 2 塊";
            // 
            // button17
            // 
            this.button17.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(192)))));
            this.button17.Location = new System.Drawing.Point(40, 267);
            this.button17.Name = "button17";
            this.button17.Size = new System.Drawing.Size(105, 30);
            this.button17.TabIndex = 34;
            this.button17.Text = "讀指定塊數據";
            this.button17.UseVisualStyleBackColor = true;
            this.button17.Click += new System.EventHandler(this.button17_Click);
            // 
            // textBox6
            // 
            this.textBox6.ForeColor = System.Drawing.Color.Red;
            this.textBox6.Location = new System.Drawing.Point(151, 269);
            this.textBox6.Name = "textBox6";
            this.textBox6.Size = new System.Drawing.Size(209, 21);
            this.textBox6.TabIndex = 35;
            // 
            // button18
            // 
            this.button18.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(192)))));
            this.button18.Location = new System.Drawing.Point(364, 263);
            this.button18.Name = "button18";
            this.button18.Size = new System.Drawing.Size(105, 30);
            this.button18.TabIndex = 36;
            this.button18.Text = "寫指定塊數據";
            this.button18.UseVisualStyleBackColor = true;
            this.button18.Click += new System.EventHandler(this.button18_Click);
            // 
            // button19
            // 
            this.button19.ForeColor = System.Drawing.Color.Red;
            this.button19.Location = new System.Drawing.Point(40, 476);
            this.button19.Name = "button19";
            this.button19.Size = new System.Drawing.Size(164, 32);
            this.button19.TabIndex = 37;
            this.button19.Text = "開始偵聽二代身份證UID";
            this.button19.UseVisualStyleBackColor = true;
            this.button19.Click += new System.EventHandler(this.button19_Click);
            // 
            // textBox8
            // 
            this.textBox8.ForeColor = System.Drawing.Color.Red;
            this.textBox8.Location = new System.Drawing.Point(210, 476);
            this.textBox8.Multiline = true;
            this.textBox8.Name = "textBox8";
            this.textBox8.Size = new System.Drawing.Size(259, 32);
            this.textBox8.TabIndex = 38;
            // 
            // button20
            // 
            this.button20.ForeColor = System.Drawing.Color.Red;
            this.button20.Location = new System.Drawing.Point(40, 524);
            this.button20.Name = "button20";
            this.button20.Size = new System.Drawing.Size(164, 32);
            this.button20.TabIndex = 39;
            this.button20.Text = "開始偵聽HID ICLASS CSN";
            this.button20.UseVisualStyleBackColor = true;
            this.button20.Click += new System.EventHandler(this.button20_Click);
            // 
            // textBox9
            // 
            this.textBox9.ForeColor = System.Drawing.Color.Red;
            this.textBox9.Location = new System.Drawing.Point(210, 525);
            this.textBox9.Multiline = true;
            this.textBox9.Name = "textBox9";
            this.textBox9.Size = new System.Drawing.Size(259, 31);
            this.textBox9.TabIndex = 40;
            // 
            // timer3
            // 
            this.timer3.Tick += new System.EventHandler(this.timer3_Tick);
            // 
            // timer4
            // 
            this.timer4.Tick += new System.EventHandler(this.timer4_Tick);
            // 
            // Form1
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(520, 577);
            this.Controls.Add(this.textBox9);
            this.Controls.Add(this.button20);
            this.Controls.Add(this.textBox8);
            this.Controls.Add(this.button19);
            this.Controls.Add(this.button18);
            this.Controls.Add(this.textBox6);
            this.Controls.Add(this.button17);
            this.Controls.Add(this.label6);
            this.Controls.Add(this.label5);
            this.Controls.Add(this.label4);
            this.Controls.Add(this.label3);
            this.Controls.Add(this.textBox7);
            this.Controls.Add(this.label2);
            this.Controls.Add(this.textBox5);
            this.Controls.Add(this.textBox2);
            this.Controls.Add(this.button16);
            this.Controls.Add(this.button15);
            this.Controls.Add(this.button14);
            this.Controls.Add(this.button13);
            this.Controls.Add(this.button10);
            this.Controls.Add(this.button12);
            this.Controls.Add(this.textBox4);
            this.Controls.Add(this.label1);
            this.Controls.Add(this.textBox3);
            this.Controls.Add(this.button11);
            this.Controls.Add(this.button9);
            this.Controls.Add(this.textBox1);
            this.Controls.Add(this.button8);
            this.Controls.Add(this.button7);
            this.Controls.Add(this.button6);
            this.Controls.Add(this.button5);
            this.Controls.Add(this.button4);
            this.Controls.Add(this.button3);
            this.Controls.Add(this.button2);
            this.Controls.Add(this.button1);
            this.MaximizeBox = false;
            this.MinimizeBox = false;
            this.Name = "Form1";
            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
            this.Text = "IC卡讀寫動態庫OUR_MIFARE.dll使用示例";
            this.Load += new System.EventHandler(this.Form1_Load);
            this.ResumeLayout(false);
            this.PerformLayout();
 
        }
 
        #endregion
 
        private System.Windows.Forms.Button button1;
        private System.Windows.Forms.Button button2;
        private System.Windows.Forms.Button button3;
        private System.Windows.Forms.Button button4;
        private System.Windows.Forms.Button button5;
        private System.Windows.Forms.Button button6;
        private System.Windows.Forms.Button button7;
        private System.Windows.Forms.Button button8;
        private System.Windows.Forms.TextBox textBox1;
        private System.Windows.Forms.Button button9;
        private System.Windows.Forms.TextBox textBox3;
        private System.Windows.Forms.Button button11;
        private System.Windows.Forms.Label label1;
        private System.Windows.Forms.TextBox textBox4;
        private System.Windows.Forms.Button button12;
        private System.Windows.Forms.Timer timer1;
        private System.Windows.Forms.Timer timer2;
        private System.Windows.Forms.Button button10;
        private System.Windows.Forms.Button button13;
        private System.Windows.Forms.Button button14;
        private System.Windows.Forms.Button button15;
        private System.Windows.Forms.Button button16;
        private System.Windows.Forms.TextBox textBox2;
        private System.Windows.Forms.TextBox textBox5;
        private System.Windows.Forms.Label label2;
        private System.Windows.Forms.TextBox textBox7;
        private System.Windows.Forms.Label label3;
        private System.Windows.Forms.Label label4;
        private System.Windows.Forms.Label label5;
        private System.Windows.Forms.Label label6;
        private System.Windows.Forms.Button button17;
        private System.Windows.Forms.TextBox textBox6;
        private System.Windows.Forms.Button button18;
        private System.Windows.Forms.Button button19;
        private System.Windows.Forms.TextBox textBox8;
        private System.Windows.Forms.Button button20;
        private System.Windows.Forms.TextBox textBox9;
        private System.Windows.Forms.Timer timer3;
        private System.Windows.Forms.Timer timer4;
    }
}

小程序代碼:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
//using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
 
using System.Runtime.InteropServices;  //調用動態庫一定要加入這個引用
using System.Text;//一定要加入這個
 
namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
      
        public const byte BLOCK0_EN = 0x01;//操作第0塊 
        public const byte BLOCK1_EN = 0x02;//操作第1塊
        public const byte BLOCK2_EN = 0x04;//操作第2塊
        public const byte NEEDSERIAL = 0x08;//僅對指定序列號的卡操作
        public const byte EXTERNKEY = 0x10;
        public const byte NEEDHALT = 0x20;//讀卡或寫卡后順便休眠該卡,休眠后,卡必須拿離開感應區,再放回感應區,才能進行第二次操作。
 
        //------------------------------------------------------------------------------------------------------------------------------------------------------
        //外部函數聲明:讓設備發出聲響
        [DllImport("OUR_MIFARE.dll", EntryPoint = "pcdbeep", CallingConvention = CallingConvention.StdCall)]
        static extern byte pcdbeep(UInt32 xms);//xms單位為毫秒 
 
 
        //------------------------------------------------------------------------------------------------------------------------------------------------------    
        //只讀卡號
        [DllImport("OUR_MIFARE.dll", EntryPoint = "piccrequest", CallingConvention = CallingConvention.StdCall)]
        public static extern byte piccrequest(byte[] serial);//devicenumber用于返回編號 
 
        //------------------------------------------------------------------------------------------------------------------------------------------------------    
        //讀取設備編號,可做為軟件加密狗用,也可以根據此編號在公司網站上查詢保修期限
        [DllImport("OUR_MIFARE.dll", EntryPoint = "pcdgetdevicenumber", CallingConvention = CallingConvention.StdCall)]
        static extern byte pcdgetdevicenumber(byte[] devicenumber);//devicenumber用于返回編號 
 
 
        //------------------------------------------------------------------------------------------------------------------------------------------------------
        //輕松讀卡
        [DllImport("OUR_MIFARE.dll", EntryPoint = "piccreadex", CallingConvention = CallingConvention.StdCall)]
        static extern byte piccreadex(byte ctrlword, byte[] serial, byte area, byte keyA1B0, byte[] picckey, byte[] piccdata0_2);
        //參數:說明
        //ctrlword:控制字
        //serial:卡序列號數組,用于指定或返回卡序列號
        //area:指定讀卡區號
        //keyA1B0:指定用A或B密碼認證,一般是用A密碼,只有特殊用途下才用B密碼,在這不做詳細解釋。
        //picckey:指定卡密碼,6個字節,卡出廠時的初始密碼為6個0xff
        //piccdata0_2:用于返回卡該區第0塊到第2塊的數據,共48個字節.
 
 
        //------------------------------------------------------------------------------------------------------------------------------------------------------
        //輕松寫卡
        [DllImport("OUR_MIFARE.dll", EntryPoint = "piccwriteex", CallingConvention = CallingConvention.StdCall)]
        static extern byte piccwriteex(byte ctrlword, byte[] serial, byte area, byte keyA1B0, byte[] picckey, byte[] piccdata0_2);
        //參數:說明
        //ctrlword:控制字
        //serial:卡序列號數組,用于指定或返回卡序列號
        //area:指定讀卡區號
        //keyA1B0:指定用A或B密碼認證,一般是用A密碼,只有特殊用途下才用B密碼,在這不做詳細解釋。
        //picckey:指定卡密碼,6個字節,卡出廠時的初始密碼為6個0xff
        //piccdata0_2:用于返回卡該區第0塊到第2塊的數據,共48個字節.
 
 
        //------------------------------------------------------------------------------------------------------------------------------------------------------
        //密碼認證方式1,用外部密碼認證,必須指定外部密碼。本函數必須在piccrequest或piccrequestex函數執行之后運行,并且要緊接著調用,中途不能調用其他函數。
        [DllImport("OUR_MIFARE.dll", EntryPoint = "piccauthkey1", CallingConvention = CallingConvention.StdCall)]
        static extern byte piccauthkey1(byte[] serial, byte area, byte keyA1B0, byte[] picckey);
        //參數:說明
        //serial:卡序列號數組,用于指定或返回卡序列號
        //area:指定讀卡區號
        //keyA1B0:指定用A或B密碼認證,一般是用A密碼,只有特殊用途下才用B密碼,在這不做詳細解釋。
        //picckey:指定卡密碼,6個字節,卡出廠時的初始密碼為6個0xff
 
 
        //------------------------------------------------------------------------------------------------------------------------------------------------------
        //讀出一塊的數據,也就是16個字節。必須在執行piccrequest或 Piccrequestex函數,接著執行piccauthkey1或 piccauthkey2函數,然后執行piccread才能成功讀出一塊的數據。
        [DllImport("OUR_MIFARE.dll", EntryPoint = "piccread", CallingConvention = CallingConvention.StdCall)]
        static extern byte piccread(byte block,  byte[] blockdata);
        //參數:說明
        //block:指定讀卡塊號
        //blockdata:用于返回卡該塊數據,共16個字節.
 
        //------------------------------------------------------------------------------------------------------------------------------------------------------
        //寫一塊的數據,也就是16個字節。必須在執行piccrequest或 Piccrequestex函數,接著執行piccauthkey1或 piccauthkey2函數,然后執行piccread才能成功讀出一塊的數據。
        [DllImport("OUR_MIFARE.dll", EntryPoint = "piccwrite", CallingConvention = CallingConvention.StdCall)]
        static extern byte piccwrite(byte block, byte[] blockdata);
        //參數:說明
        //block:指定寫卡塊號
        //blockdata:寫塊數據緩沖,共16個字節.
 
 
        //------------------------------------------------------------------------------------------------------------------------------------------------------
        //修改卡單區的密碼
        [DllImport("OUR_MIFARE.dll", EntryPoint = "piccchangesinglekey", CallingConvention = CallingConvention.StdCall)]
        static extern byte piccchangesinglekey(byte ctrlword, byte[] serial, byte area, byte keyA1B0, byte[] piccoldkey, byte[] piccnewkey);
        //參數:說明
        //ctrlword:控制字
        //serial:卡序列號數組,用于指定或返回卡序列號
        //area:指定讀卡區號
        //keyA1B0:指定用A或B密碼認證,一般是用A密碼,只有特殊用途下才用B密碼,在這不做詳細解釋。
        //piccoldkey://舊密碼
        //piccnewkey://新密碼.
 
        //------------------------------------------------------------------------------------------------------------------------------------------------------
        //修改卡A/B密碼及控制字
        [DllImport("OUR_MIFARE.dll", EntryPoint = "piccchangesinglekeyex", CallingConvention = CallingConvention.StdCall)]
        static extern byte piccchangesinglekeyex(byte ctrlword, byte[] serial, byte area, byte keyA1B0, byte[] piccoldkey, byte[] piccnewkey);
        //參數:說明
        //ctrlword:控制字
        //serial:卡序列號數組,用于指定或返回卡序列號
        //area:指定讀卡區號
        //keyA1B0:指定用A或B密碼認證,一般是用A密碼,只有特殊用途下才用B密碼,在這不做詳細解釋。
        //piccoldkey://舊密碼
        //piccnewkey://新密碼.
 
        //------------------------------------------------------------------------------------------------------------------------------------------------------
        //發送顯示內容到讀卡器
        [DllImport("OUR_MIFARE.dll", EntryPoint = "lcddispfull", CallingConvention = CallingConvention.StdCall)]
        static extern byte lcddispfull(string lcdstr);
        //參數:說明
        //lcdstr:顯示內容
 
 
        //------------------------------------------------------------------------------------------------------------------------------------------------------    
        //寫設備存儲區1
        [DllImport("OUR_MIFARE.dll", EntryPoint = "pcdsetcustomizedata1", CallingConvention = CallingConvention.StdCall)]
        public static extern byte pcdsetcustomizedata1(byte[] readerdata);//devicenumber用于傳遞寫數據 
 
        //------------------------------------------------------------------------------------------------------------------------------------------------------    
        //讀設備存儲區1
        [DllImport("OUR_MIFARE.dll", EntryPoint = "pcdgetcustomizedata1", CallingConvention = CallingConvention.StdCall)]
        public static extern byte pcdgetcustomizedata1(byte[] readerdata);//devicenumber用于傳遞寫數據 
 
        //------------------------------------------------------------------------------------------------------------------------------------------------------    
        //寫設備存儲區2
        [DllImport("OUR_MIFARE.dll", EntryPoint = "pcdsetcustomizedata2", CallingConvention = CallingConvention.StdCall)]
        public static extern byte pcdsetcustomizedata2(byte[] readerdata);//devicenumber用于傳遞寫數據 
 
        //------------------------------------------------------------------------------------------------------------------------------------------------------    
        //讀設備存儲區2
        [DllImport("OUR_MIFARE.dll", EntryPoint = "pcdgetcustomizedata2", CallingConvention = CallingConvention.StdCall)]
        public static extern byte pcdgetcustomizedata2(byte[] readerdata, byte[] devno);//devicenumber用于傳遞寫數據 
 
 
        //------------------------------------------------------------------------------------------------------------------------------------------------------    
        //讀二代身份證UID
        [DllImport("OUR_MIFARE.dll", EntryPoint = "sfzrequest", CallingConvention = CallingConvention.StdCall)]
        public static extern byte sfzrequest(byte[] serial);//devicenumber用于返回UID號 
 
        //------------------------------------------------------------------------------------------------------------------------------------------------------    
        //讀HID ICLASS CSN
        [DllImport("OUR_MIFARE.dll", EntryPoint = "iso15693iclassreadcsn", CallingConvention = CallingConvention.StdCall)]
        public static extern byte iso15693iclassreadcsn(byte[] serial);//devicenumber用于返回CSN號 
 
        public Form1()
        {
            InitializeComponent();
        }
 
        private void button1_Click(object sender, EventArgs e)//輕松讀卡
        {
            byte status;//存放返回值
            byte myareano;//區號
            byte authmode;//密碼類型,用A密碼或B密碼
            byte myctrlword;//控制字
            byte[] mypicckey = new byte[6];//密碼
            byte[] mypiccserial = new byte[4];//卡序列號
            byte[] mypiccdata = new byte[48]; //卡數據緩沖
            //控制字指定,控制字的含義請查看本公司網站提供的動態庫說明
            myctrlword = BLOCK0_EN + BLOCK1_EN + BLOCK2_EN + EXTERNKEY;
 
            //指定區號
            myareano = 8;//指定為第8區
            //批定密碼模式
            authmode = 1;//大于0表示用A密碼認證,推薦用A密碼認證
 
            //指定密碼
            mypicckey[0] = 0xff;
            mypicckey[1] = 0xff;
            mypicckey[2] = 0xff;
            mypicckey[3] = 0xff;
            mypicckey[4] = 0xff;
            mypicckey[5] = 0xff;
 
            status = piccreadex(myctrlword, mypiccserial, myareano, authmode, mypicckey, mypiccdata);
            //在下面設定斷點,然后查看mypiccserial、mypiccdata,
            //調用完 piccreadex函數可讀出卡序列號到 mypiccserial,讀出卡數據到mypiccdata,
            //開發人員根據自己的需要處理mypiccserial、mypiccdata 中的數據了。
            //處理返回函數
            switch (status)
            {
                case 0:
                    pcdbeep(20);
                    string readinf = "";
                    for (int i = 0; i < 48;i++ )
                    {
                        readinf = readinf + mypiccdata[i].ToString("X2");
                    }
                    textBox7.Text = readinf;
                    MessageBox.Show("操作成功,數據已顯示在右框欄中!","示例程序");
                    break;
                case 8:
                    MessageBox.Show("未尋到卡,請將卡放在感應區!", "示例提示");
                    break;
                case 9:
                    MessageBox.Show("讀序列碼錯誤!", "示例提示");
                    break;
                case 10:
                    MessageBox.Show("選卡錯誤!", "示例提示");
                    break;
                case 11:
                    MessageBox.Show("裝載密碼錯誤!", "示例提示");
                    break;
                case 12:
                    MessageBox.Show("卡密碼認證錯誤!", "示例提示");
                    break;
                case 13:
                    MessageBox.Show("讀卡錯誤!", "示例提示");
                    break;
                case 14:
                    MessageBox.Show("寫卡錯誤!", "示例提示");
                    break;
                case 21:
                    MessageBox.Show("沒有動態庫!", "示例提示");
                    break;
                case 22:
                    MessageBox.Show("動態庫或驅動程序異常!", "示例提示");
                    break;
                case 23:
                    MessageBox.Show("驅動程序錯誤或尚未安裝!", "示例提示");
                    break;
                case 24:
                    MessageBox.Show("操作超時,一般是動態庫沒有反映!", "示例提示");
                    break;
                case 25:
                    MessageBox.Show("發送字數不夠!", "示例提示");
                    break;
                case 26:
                    MessageBox.Show("發送的CRC錯!", "示例提示");
                    break;
                case 27:
                    MessageBox.Show("接收的字數不夠!", "示例提示");
                    break;
                case 28:
                    MessageBox.Show("接收的CRC錯!", "示例提示");
                    break;
                default:
                    MessageBox.Show("返回碼(對應的說明請看例子中的注釋):" + status, "示例提示");
                    break;
            }
 
 
            //返回解釋
            /*
            REQUEST 8//尋卡錯誤
            READSERIAL 9//讀序列嗎錯誤
            SELECTCARD 10//選卡錯誤
            LOADKEY 11//裝載密碼錯誤
            AUTHKEY 12//密碼認證錯誤
            READ 13//讀卡錯誤
            WRITE 14//寫卡錯誤
 
            NONEDLL 21//沒有動態庫
            DRIVERORDLL 22//動態庫或驅動程序異常
            DRIVERNULL 23//驅動程序錯誤或尚未安裝
            TIMEOUT 24//操作超時,一般是動態庫沒有反映
            TXSIZE 25//發送字數不夠
            TXCRC 26//發送的CRC錯
            RXSIZE 27//接收的字數不夠
            RXCRC 28//接收的CRC錯
 
 
 
            */
        }
 
        private void button2_Click(object sender, EventArgs e)//輕松寫卡
        {
            byte i;
            byte status;//存放返回值
            byte myareano;//區號
            byte authmode;//密碼類型,用A密碼或B密碼
            byte myctrlword;//控制字
            byte[] mypicckey = new byte[6];//密碼
            byte[] mypiccserial = new byte[4];//卡序列號
            byte[] mypiccdata = new byte[48]; //卡數據緩沖
            //控制字指定,控制字的含義請查看本公司網站提供的動態庫說明
 
            myctrlword = BLOCK0_EN + BLOCK1_EN + BLOCK2_EN + EXTERNKEY;
 
            //指定區號
            myareano = 8;//指定為第8區
            //批定密碼模式
            authmode = 1;//大于0表示用A密碼認證,推薦用A密碼認證
 
            //指定密碼
            mypicckey[0] = 0xff;
            mypicckey[1] = 0xff;
            mypicckey[2] = 0xff;
            mypicckey[3] = 0xff;
            mypicckey[4] = 0xff;
            mypicckey[5] = 0xff;
 
            //指定卡數據
            string writinf = textBox7.Text.Trim() + "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000";
            for (i = 0; i < 48; i++)
            {
                mypiccdata[i] = Convert.ToByte(Convert.ToInt32(writinf.Substring(i * 2, 2), 16));
            }
 
            status = piccwriteex(myctrlword, mypiccserial, myareano, authmode, mypicckey, mypiccdata);
            //在下面設定斷點,然后查看mypiccserial、mypiccdata,
            //調用完 piccreadex函數可讀出卡序列號到 mypiccserial,讀出卡數據到mypiccdata,
            //開發人員根據自己的需要處理mypiccserial、mypiccdata 中的數據了。
            //處理返回函數
            switch (status)
            {
                case 0:
                    pcdbeep(50);
                    MessageBox.Show("操作成功,右欄數據已寫入卡中!", "示例提示");
                    break;
                case 8:
                    MessageBox.Show("未尋到卡,請將卡放在感應區!", "示例提示");
                    break;
                case 9:
                    MessageBox.Show("讀序列碼錯誤!", "示例提示");
                    break;
                case 10:
                    MessageBox.Show("選卡錯誤!", "示例提示");
                    break;
                case 11:
                    MessageBox.Show("裝載密碼錯誤!", "示例提示");
                    break;
                case 12:
                    MessageBox.Show("卡密碼認證錯誤!", "示例提示");
                    break;
                case 13:
                    MessageBox.Show("讀卡錯誤!", "示例提示");
                    break;
                case 14:
                    MessageBox.Show("寫卡錯誤!", "示例提示");
                    break;
                case 21:
                    MessageBox.Show("沒有動態庫!", "示例提示");
                    break;
                case 22:
                    MessageBox.Show("動態庫或驅動程序異常!", "示例提示");
                    break;
                case 23:
                    MessageBox.Show("驅動程序錯誤或尚未安裝!", "示例提示");
                    break;
                case 24:
                    MessageBox.Show("操作超時,一般是動態庫沒有反映!", "示例提示");
                    break;
                case 25:
                    MessageBox.Show("發送字數不夠!", "示例提示");
                    break;
                case 26:
                    MessageBox.Show("發送的CRC錯!", "示例提示");
                    break;
                case 27:
                    MessageBox.Show("接收的字數不夠!", "示例提示");
                    break;
                case 28:
                    MessageBox.Show("接收的CRC錯!", "示例提示");
                    break;
                default:
                    MessageBox.Show("返回碼(對應的說明請看例子中的注釋):" + status, "示例提示");
                    break;
            }
 
 
            //返回解釋
            /*
            REQUEST 8//尋卡錯誤
            READSERIAL 9//讀序列嗎錯誤
            SELECTCARD 10//選卡錯誤
            LOADKEY 11//裝載密碼錯誤
            AUTHKEY 12//密碼認證錯誤
            READ 13//讀卡錯誤
            WRITE 14//寫卡錯誤
 
            NONEDLL 21//沒有動態庫
            DRIVERORDLL 22//動態庫或驅動程序異常
            DRIVERNULL 23//驅動程序錯誤或尚未安裝
            TIMEOUT 24//操作超時,一般是動態庫沒有反映
            TXSIZE 25//發送字數不夠
            TXCRC 26//發送的CRC錯
            RXSIZE 27//接收的字數不夠
            RXCRC 28//接收的CRC錯
 
 
 
            */
        }
 
        private void button4_Click(object sender, EventArgs e)
        {
            pcdbeep(50);
        }
 
        private void button3_Click(object sender, EventArgs e)
        {
            byte status;//存放返回值
            byte myareano;//區號
            byte authmode;//密碼類型,用A密碼或B密碼
            byte myctrlword;//控制字
            byte[] piccoldkey = new byte[6];//舊密碼
            byte[] mypiccserial = new byte[4];//卡序列號
            byte[] piccnewkey = new byte[6]; //新密碼.
 
 
            //控制字指定,控制字的含義請查看本公司網站提供的動態庫說明
            myctrlword = 0;
 
            //指定區號
            myareano = 8;//指定為第8區
            //批定密碼模式
            authmode = 1;//大于0表示用A密碼認證,推薦用A密碼認證
 
            //指定舊密碼
            piccoldkey[0] = 0xff;
            piccoldkey[1] = 0xff;
            piccoldkey[2] = 0xff;
            piccoldkey[3] = 0xff;
            piccoldkey[4] = 0xff;
            piccoldkey[5] = 0xff;
 
            //指定新密碼,注意:指定新密碼時一定要記住,否則有可能找不回密碼,導致該卡報廢。
            piccnewkey[0] = 0xff;
            piccnewkey[1] = 0xff;
            piccnewkey[2] = 0xff;
            piccnewkey[3] = 0xff;
            piccnewkey[4] = 0xff;
            piccnewkey[5] = 0xff;
 
            status = piccchangesinglekey(myctrlword, mypiccserial, myareano, authmode, piccoldkey, piccnewkey);
            //在下面設定斷點,然后查看mypiccserial、mypiccdata,
            //調用完 piccreadex函數可讀出卡序列號到 mypiccserial,讀出卡數據到mypiccdata,
            //開發人員根據自己的需要處理mypiccserial、mypiccdata 中的數據了。
            //處理返回函數
            switch (status)
            {
                case 0:
                    MessageBox.Show("操作成功,密碼已被修改!");
                    break;
                case 8:
                    MessageBox.Show("未尋到卡,請將卡放在感應區!", "示例提示");
                    break;
                case 9:
                    MessageBox.Show("讀序列碼錯誤!", "示例提示");
                    break;
                case 10:
                    MessageBox.Show("選卡錯誤!", "示例提示");
                    break;
                case 11:
                    MessageBox.Show("裝載密碼錯誤!", "示例提示");
                    break;
                case 12:
                    MessageBox.Show("卡密碼認證錯誤!", "示例提示");
                    break;
                case 13:
                    MessageBox.Show("讀卡錯誤!", "示例提示");
                    break;
                case 14:
                    MessageBox.Show("寫卡錯誤!", "示例提示");
                    break;
                case 21:
                    MessageBox.Show("沒有動態庫!", "示例提示");
                    break;
                case 22:
                    MessageBox.Show("動態庫或驅動程序異常!", "示例提示");
                    break;
                case 23:
                    MessageBox.Show("驅動程序錯誤或尚未安裝!", "示例提示");
                    break;
                case 24:
                    MessageBox.Show("操作超時,一般是動態庫沒有反映!", "示例提示");
                    break;
                case 25:
                    MessageBox.Show("發送字數不夠!", "示例提示");
                    break;
                case 26:
                    MessageBox.Show("發送的CRC錯!", "示例提示");
                    break;
                case 27:
                    MessageBox.Show("接收的字數不夠!", "示例提示");
                    break;
                case 28:
                    MessageBox.Show("接收的CRC錯!", "示例提示");
                    break;
                default:
                    MessageBox.Show("返回碼(對應的說明請看例子中的注釋):" + status, "示例提示");
                    break;
            }
 
 
            //返回解釋
            /*
            REQUEST 8//尋卡錯誤
            READSERIAL 9//讀序列嗎錯誤
            SELECTCARD 10//選卡錯誤
            LOADKEY 11//裝載密碼錯誤
            AUTHKEY 12//密碼認證錯誤
            READ 13//讀卡錯誤
            WRITE 14//寫卡錯誤
 
            NONEDLL 21//沒有動態庫
            DRIVERORDLL 22//動態庫或驅動程序異常
            DRIVERNULL 23//驅動程序錯誤或尚未安裝
            TIMEOUT 24//操作超時,一般是動態庫沒有反映
            TXSIZE 25//發送字數不夠
            TXCRC 26//發送的CRC錯
            RXSIZE 27//接收的字數不夠
            RXCRC 28//接收的CRC錯
 
            */
        }
 
        private void button8_Click(object sender, EventArgs e)//讀取設備編號,可做為軟件加密狗用,也可以根據此編號在公司網站上查詢保修期限
        {
            byte[] devno = new byte[4];
            if (pcdgetdevicenumber(devno) == 0)
            {
                pcdbeep(50);
                MessageBox.Show("設備的序列號為:"+System.Convert.ToString(devno[0]) + "-" + System.Convert.ToString(devno[1]) + "-" + System.Convert.ToString(devno[2]) + "-" + System.Convert.ToString(devno[3]),"示例程序");
                //ShowMessage(IntToStr(devno[0]) + "-" + IntToStr(devno[1]) + "-" + IntToStr(devno[2]) + "-" + IntToStr(devno[3]));
            }
        }
 
        private void button9_Click(object sender, EventArgs e)
        {
            string strls;
            strls = textBox1.Text;
            lcddispfull(strls);
        }
 
        private void button7_Click(object sender, EventArgs e)
        {
            if (button7.Text == "每十秒讀一次")
            {
                pcdbeep(5);
                byte[] devno = new byte[4];
                if (pcdgetdevicenumber(devno) == 0)
                {
                    textBox4.Text = System.Convert.ToString(devno[0]) + "-" + System.Convert.ToString(devno[1]) + "-" + System.Convert.ToString(devno[2]) + "-" + System.Convert.ToString(devno[3]);
                }
                else
                { textBox4.Text = ""; }
 
                button12.Text = "輪詢讀IC卡號";
                timer1.Enabled = false;
                timer2.Enabled = true;
                button7.Text = "暫停";
            }
            else
            {
                timer2.Enabled = false;
                button7.Text = "每十秒讀一次";
            }
        }
 
        private void button11_Click(object sender, EventArgs e)
        {
            string cardstr;
            byte status;//Store the return value
            byte[] mypiccserial = new byte[4];//card serial
            Int64 cardnumdec;
            status = piccrequest(mypiccserial);
            if (status == 0)
            {
                cardnumdec = mypiccserial[3];
                cardnumdec = cardnumdec * 256;
                cardnumdec = cardnumdec + mypiccserial[2];
                cardnumdec = cardnumdec * 256;
                cardnumdec = cardnumdec + mypiccserial[1];
                cardnumdec = cardnumdec * 256;
                cardnumdec = cardnumdec + mypiccserial[0];
                cardstr = "0000000000" + Convert.ToString(cardnumdec);
                textBox3.Text = cardstr.Substring(cardstr.Length-10)   ;
                pcdbeep(38);
            }
        }
 
        private void button5_Click(object sender, EventArgs e)
        {
            string strls;
            byte i;
            byte status;//存放返回值
            byte myareano;//區號
            byte authmode;//密碼類型,用A密碼或B密碼
            byte myctrlword;//控制字
            byte[] mypicckey = new byte[6];//密碼
            byte[] mypiccserial = new byte[4];//卡序列號
            byte[] mypiccdata = new byte[48]; //卡數據緩沖
            //控制字指定,控制字的含義請查看本公司網站提供的動態庫說明
 
            myctrlword = BLOCK0_EN + BLOCK1_EN + BLOCK2_EN + EXTERNKEY;
 
            //指定區號
            myareano = 8;//指定為第8區
            //批定密碼模式
            authmode = 1;//大于0表示用A密碼認證,推薦用A密碼認證
 
            //指定密碼
            mypicckey[0] = 0xff;
            mypicckey[1] = 0xff;
            mypicckey[2] = 0xff;
            mypicckey[3] = 0xff;
            mypicckey[4] = 0xff;
            mypicckey[5] = 0xff;
 
 
            strls = textBox1.Text + "                                                 ";
            byte[] strlsansi = System.Text.Encoding.GetEncoding(936).GetBytes(strls);//轉換為Ansi
            for (i = 0; i < 48; i++)
            {
                mypiccdata[i] = strlsansi[i];
            }
 
            status = piccwriteex(myctrlword, mypiccserial, myareano, authmode, mypicckey, mypiccdata);
            //在下面設定斷點,然后查看mypiccserial、mypiccdata,
            //調用完 piccreadex函數可讀出卡序列號到 mypiccserial,讀出卡數據到mypiccdata,
            //開發人員根據自己的需要處理mypiccserial、mypiccdata 中的數據了。
            //處理返回函數
            switch (status)
            {
                case 0:
                    pcdbeep(50);
                    MessageBox.Show("操作成功,下欄文字信息已寫入卡中!","示例提示");
                    break;
                case 8:
                    MessageBox.Show("未尋到卡,請將卡放在感應區!", "示例提示");
                    break;
                case 9:
                    MessageBox.Show("讀序列碼錯誤!", "示例提示");
                    break;
                case 10:
                    MessageBox.Show("選卡錯誤!", "示例提示");
                    break;
                case 11:
                    MessageBox.Show("裝載密碼錯誤!", "示例提示");
                    break;
                case 12:
                    MessageBox.Show("卡密碼認證錯誤!", "示例提示");
                    break;
                case 13:
                    MessageBox.Show("讀卡錯誤!", "示例提示");
                    break;
                case 14:
                    MessageBox.Show("寫卡錯誤!", "示例提示");
                    break;
                case 21:
                    MessageBox.Show("沒有動態庫!", "示例提示");
                    break;
                case 22:
                    MessageBox.Show("動態庫或驅動程序異常!", "示例提示");
                    break;
                case 23:
                    MessageBox.Show("驅動程序錯誤或尚未安裝!", "示例提示");
                    break;
                case 24:
                    MessageBox.Show("操作超時,一般是動態庫沒有反映!", "示例提示");
                    break;
                case 25:
                    MessageBox.Show("發送字數不夠!", "示例提示");
                    break;
                case 26:
                    MessageBox.Show("發送的CRC錯!", "示例提示");
                    break;
                case 27:
                    MessageBox.Show("接收的字數不夠!", "示例提示");
                    break;
                case 28:
                    MessageBox.Show("接收的CRC錯!", "示例提示");
                    break;
                default:
                    MessageBox.Show("返回碼(對應的說明請看例子中的注釋):" + status, "示例提示");
                    break;
 
            }
        }
 
        private void button6_Click(object sender, EventArgs e)
        {
            byte status;//存放返回值
            byte myareano;//區號
            byte authmode;//密碼類型,用A密碼或B密碼
            byte myctrlword;//控制字
            byte[] mypicckey = new byte[6];//密碼
            byte[] mypiccserial = new byte[4];//卡序列號
            byte[] mypiccdata = new byte[48]; //卡數據緩沖
            //控制字指定,控制字的含義請查看本公司網站提供的動態庫說明
            myctrlword = BLOCK0_EN + BLOCK1_EN + BLOCK2_EN + EXTERNKEY;
 
            //指定區號
            myareano = 8;//指定為第8區
            //批定密碼模式
            authmode = 1;//大于0表示用A密碼認證,推薦用A密碼認證
 
            //指定密碼
            mypicckey[0] = 0xff;
            mypicckey[1] = 0xff;
            mypicckey[2] = 0xff;
            mypicckey[3] = 0xff;
            mypicckey[4] = 0xff;
            mypicckey[5] = 0xff;
 
            status = piccreadex(myctrlword, mypiccserial, myareano, authmode, mypicckey, mypiccdata);
            //在下面設定斷點,然后查看mypiccserial、mypiccdata,
            //調用完 piccreadex函數可讀出卡序列號到 mypiccserial,讀出卡數據到mypiccdata,
            //開發人員根據自己的需要處理mypiccserial、mypiccdata 中的數據了。
            //處理返回函數
            switch (status)
            {
                case 0:
                    string getdata = Encoding.Default.GetString(mypiccdata);
                    MessageBox.Show("讀卡操作成功,卡內信息:"+getdata, "示例程序");
                    break;
                case 8:
                    MessageBox.Show("未尋到卡,請將卡放在感應區!", "示例提示");
                    break;
                case 9:
                    MessageBox.Show("讀序列碼錯誤!", "示例提示");
                    break;
                case 10:
                    MessageBox.Show("選卡錯誤!", "示例提示");
                    break;
                case 11:
                    MessageBox.Show("裝載密碼錯誤!", "示例提示");
                    break;
                case 12:
                    MessageBox.Show("卡密碼認證錯誤!", "示例提示");
                    break;
                case 13:
                    MessageBox.Show("讀卡錯誤!", "示例提示");
                    break;
                case 14:
                    MessageBox.Show("寫卡錯誤!", "示例提示");
                    break;
                case 21:
                    MessageBox.Show("沒有動態庫!", "示例提示");
                    break;
                case 22:
                    MessageBox.Show("動態庫或驅動程序異常!", "示例提示");
                    break;
                case 23:
                    MessageBox.Show("驅動程序錯誤或尚未安裝!", "示例提示");
                    break;
                case 24:
                    MessageBox.Show("操作超時,一般是動態庫沒有反映!", "示例提示");
                    break;
                case 25:
                    MessageBox.Show("發送字數不夠!", "示例提示");
                    break;
                case 26:
                    MessageBox.Show("發送的CRC錯!", "示例提示");
                    break;
                case 27:
                    MessageBox.Show("接收的字數不夠!", "示例提示");
                    break;
                case 28:
                    MessageBox.Show("接收的CRC錯!", "示例提示");
                    break;
                default:
                    MessageBox.Show("返回碼(對應的說明請看例子中的注釋):" + status, "示例提示");
                    break;
            }
        }
 
        private void timer2_Tick(object sender, EventArgs e)
        {
            byte[] devno = new byte[4];
            if (pcdgetdevicenumber(devno) == 0)
            {
                pcdbeep(20);
                textBox4.Text = System.Convert.ToString(devno[0]) + "-" + System.Convert.ToString(devno[1]) + "-" + System.Convert.ToString(devno[2]) + "-" + System.Convert.ToString(devno[3]);
            }
            else
            { textBox4.Text = ""; }
        }
 
        private void button10_Click(object sender, EventArgs e)
        {
 
        }
 
        private void button12_Click(object sender, EventArgs e)
        {
            if (button12.Text == "輪詢讀IC卡號")
            {
                button7.Text = "每十秒讀一次";
                timer2.Enabled = false;
                timer1.Enabled = true;
                button12.Text = "暫停";
            }
            else
            {
                timer1.Enabled = false;
                button12.Text = "輪詢讀IC卡號";
            }
        }
 
        private void timer1_Tick(object sender, EventArgs e)
        {
            byte status;//Store the return value
            byte[] mypiccserial = new byte[4];//card serial
            Int64 cardnumdec;
            status = piccrequest(mypiccserial);
            if (status == 0)
            {
                cardnumdec = mypiccserial[3];
                cardnumdec = cardnumdec * 256;
                cardnumdec = cardnumdec + mypiccserial[2];
                cardnumdec = cardnumdec * 256;
                cardnumdec = cardnumdec + mypiccserial[1];
                cardnumdec = cardnumdec * 256;
                cardnumdec = cardnumdec + mypiccserial[0];                
                string cardstr = "0000000000" + Convert.ToString(cardnumdec);
                textBox3.Text = cardstr.Substring(cardstr.Length - 10);
                pcdbeep(38);
            }
        }
 
        private void Form1_Load(object sender, EventArgs e)
        {
 
        }
 
        private void button10_Click_1(object sender, EventArgs e)
        {
            byte status;//存放返回值
            byte myareano;//區號
            byte authmode;//密碼類型,用A密碼或B密碼
            byte myctrlword;//控制字
            byte[] piccoldkey = new byte[6];//舊密碼
            byte[] mypiccserial = new byte[4];//卡序列號
            byte[] piccnewkey = new byte[17]; //新密碼.
 
 
            //控制字指定,控制字的含義請查看本公司網站提供的動態庫說明
            myctrlword = BLOCK0_EN + BLOCK1_EN + BLOCK2_EN + EXTERNKEY;
 
            //指定區號
            myareano = 8;//指定為第8區
            //批定密碼模式
            authmode = 1;//大于0表示用A密碼認證,推薦用A密碼認證
 
            //指定舊密碼
            piccoldkey[0] = 0xff;
            piccoldkey[1] = 0xff;
            piccoldkey[2] = 0xff;
            piccoldkey[3] = 0xff;
            piccoldkey[4] = 0xff;
            piccoldkey[5] = 0xff;
 
            //指定新密碼,注意:指定新密碼時一定要記住,否則有可能找不回密碼,導致該卡報廢。
            piccnewkey[0] = 0xff;  //A密碼
            piccnewkey[1] = 0xff;
            piccnewkey[2] = 0xff;
            piccnewkey[3] = 0xff;
            piccnewkey[4] = 0xff;
            piccnewkey[5] = 0xff;
 
            piccnewkey[6] = 0xff;  //控制字,除非您確定了解控制字的含意,否則不要更改,錯改卡將報廢
            piccnewkey[7] = 0x07;
            piccnewkey[8] = 0x80;
            piccnewkey[9] = 0x69;
 
            piccnewkey[10] = 0xff;  //B密碼
            piccnewkey[11] = 0xff;
            piccnewkey[12] = 0xff;
            piccnewkey[13] = 0xff;
            piccnewkey[14] = 0xff;
            piccnewkey[15] = 0xff;
 
            piccnewkey[16] = 0x03;  //'3是表示同時更改A、B、 密碼權限訪問字,為2表示密碼權限訪問字不更改,只改A、B密碼,為0表示只改A密碼
            status = piccchangesinglekeyex(myctrlword, mypiccserial, myareano, authmode, piccoldkey, piccnewkey);
            //在下面設定斷點,然后查看mypiccserial、mypiccdata,
            //調用完 piccreadex函數可讀出卡序列號到 mypiccserial,讀出卡數據到mypiccdata,
            //開發人員根據自己的需要處理mypiccserial、mypiccdata 中的數據了。
            //處理返回函數
            switch (status)
            {
                case 0:
                    pcdbeep(50);
                    MessageBox.Show("操作成功,密碼已被修改!", "示例提示");
                    break;
                case 8:
                    MessageBox.Show("未尋到卡,請將卡放在感應區!", "示例提示");
                    break;
                case 9:
                    MessageBox.Show("讀序列碼錯誤!", "示例提示");
                    break;
                case 10:
                    MessageBox.Show("選卡錯誤!", "示例提示");
                    break;
                case 11:
                    MessageBox.Show("裝載密碼錯誤!", "示例提示");
                    break;
                case 12:
                    MessageBox.Show("卡密碼認證錯誤!", "示例提示");
                    break;
                case 13:
                    MessageBox.Show("讀卡錯誤!", "示例提示");
                    break;
                case 14:
                    MessageBox.Show("寫卡錯誤!", "示例提示");
                    break;
                case 21:
                    MessageBox.Show("沒有動態庫!", "示例提示");
                    break;
                case 22:
                    MessageBox.Show("動態庫或驅動程序異常!", "示例提示");
                    break;
                case 23:
                    MessageBox.Show("驅動程序錯誤或尚未安裝!", "示例提示");
                    break;
                case 24:
                    MessageBox.Show("操作超時,一般是動態庫沒有反映!", "示例提示");
                    break;
                case 25:
                    MessageBox.Show("發送字數不夠!", "示例提示");
                    break;
                case 26:
                    MessageBox.Show("發送的CRC錯!", "示例提示");
                    break;
                case 27:
                    MessageBox.Show("接收的字數不夠!", "示例提示");
                    break;
                case 28:
                    MessageBox.Show("接收的CRC錯!", "示例提示");
                    break;
                default:
                    MessageBox.Show("返回碼(對應的說明請看例子中的注釋):" + status, "示例提示");
                    break;
            }
        }
        private void button14_Click(object sender, EventArgs e)
        {
            byte status;//Store the return value
            byte[] memo1 = new byte[4];//machinmemo1
            string readinf;
            status = pcdgetcustomizedata1(memo1);
            if (status == 0)
            {
                readinf = "";
                for (int i = 0; i < 4;i++ )
                {
                    readinf = readinf + memo1[i].ToString("X2");
                }
                textBox2.Text = readinf;
                pcdbeep(38);
            }
        }
        private void button13_Click(object sender, EventArgs e)
        {
            byte[] memo1 = new byte[4];
            string writinf;
            writinf = textBox2.Text.Trim()+"00000000";
            for (int i=0;i

聲明:本文內容及配圖由入駐作者撰寫或者入駐合作網站授權轉載。文章觀點僅代表作者本人,不代表電子發燒友網立場。文章及其配圖僅供工程師學習之用,如有內容侵權或者其他違規問題,請聯系本站處理。 舉報投訴
  • IC
    IC
    +關注

    關注

    36

    文章

    5957

    瀏覽量

    175734
  • usb
    usb
    +關注

    關注

    60

    文章

    7951

    瀏覽量

    264917
  • 小程序
    +關注

    關注

    1

    文章

    238

    瀏覽量

    12155
收藏 人收藏

    評論

    相關推薦

    68013UVC協議USB攝像頭開發板有源碼

    還在苦苦研究UVC協議的同學們,好消息來了:68013UVC協議USB攝像頭開發板及源碼開賣
    發表于 12-20 15:29

    ACR39U-H1 應用程序編程接口 ISO 7816讀寫器

    `ACR39U-H1應用程序編程接口ISO 7816讀寫器 ACR39U-H1安裝簡單、使用方便,能夠輕松集成進計算機環境。它符合PC/SC和CCID標準,驅動程序與Windows?
    發表于 08-01 16:15

    ACR39U-NF接觸式IC讀寫器USB Type-C創新解決方案

    `ACR39U-NF接觸式IC讀寫器USB Type-C創新解決方案采用USB Type-
    發表于 08-01 16:28

    非接觸IC讀寫程序

    風靡全球的非接觸IC(即感應)的應用越來越廣泛,本站特為這些朋友推出《非接觸IC讀寫
    發表于 03-27 19:00 ?104次下載

    IC 接口芯片TDA8007 讀寫器設計

    闡述T=0 傳輸協議,給出IC 讀寫器中使用的IC APDU 指令流程和原理框圖;重點介紹其
    發表于 05-15 15:43 ?85次下載

    基于PIC單片機的IC讀寫器的設計

    摘要:本文介紹了以PIC16C74單片機為核心的IC讀寫器的系統設計,系統實現了IC及外部存
    發表于 12-22 21:52 ?216次下載

    IC讀寫器電路圖

    IC讀寫器電路圖    圖為IC
    發表于 01-14 22:09 ?3311次閱讀
    <b class='flag-5'>IC</b><b class='flag-5'>卡</b><b class='flag-5'>讀寫器</b>電路圖

    公交非接觸IC讀寫器的應用設計

    公交非接觸IC讀寫器的應用設計 采用PHILIPS公司的MifareIC,設計以射頻技
    發表于 01-13 10:07 ?2330次閱讀

    IC讀寫器接口函數規范

    本內容詳細介紹了IC讀寫器接口函數規范,歡迎大家下載學習
    發表于 07-26 16:33 ?137次下載
    <b class='flag-5'>IC</b><b class='flag-5'>卡</b><b class='flag-5'>讀寫器</b>接口函數規范

    C#教程之IC讀寫

    C#教程之IC讀寫,很好的C#資料,快來學習吧。
    發表于 04-21 09:52 ?26次下載

    IC讀寫器使用說明

    IC讀寫器使用說明,有需要的朋友下來看看
    發表于 07-15 16:03 ?6次下載

    如何使用PIC單片機實現IC讀寫器的設計

    本文介紹了以 PIC16C74 單片機為核心的 IC 讀寫器的系統設計,系統實現了 IC
    發表于 01-02 08:00 ?1次下載
    如何使用PIC單片機實現<b class='flag-5'>IC</b><b class='flag-5'>卡</b><b class='flag-5'>讀寫器</b>的設計

    ic讀寫器怎么用

    IC讀寫器有人也稱讀卡IC 卡具有存儲容量大、保密性好、體積小、便于攜帶等特點, 可廣泛用于金融、交通、稅務、社會保險、工商管理、醫療
    的頭像 發表于 08-07 09:11 ?1.7w次閱讀

    C++ QT開發IC讀寫器程序

    第一步:新建一個qt C++項目 在此需要注意, 名稱和路徑不能有中文。 第二步: 添加控件 完成UI布局 IC讀寫器讀寫IC
    的頭像 發表于 12-30 14:55 ?71次閱讀
    <b class='flag-5'>C</b>++ QT<b class='flag-5'>開發</b>,<b class='flag-5'>IC</b><b class='flag-5'>讀寫器</b><b class='flag-5'>程序</b>

    USB協議IC讀寫器 QT程序開發

    ? 讀取15693IC讀卡如下入所示: 15693卡片,通常指的是符合ISO/IEC 15693標準的非接觸式智能或RFID。以下
    的頭像 發表于 12-30 17:42 ?102次閱讀
    <b class='flag-5'>USB</b><b class='flag-5'>免</b><b class='flag-5'>驅</b><b class='flag-5'>全</b><b class='flag-5'>協議</b><b class='flag-5'>IC</b><b class='flag-5'>卡</b><b class='flag-5'>讀寫器</b> QT<b class='flag-5'>程序</b><b class='flag-5'>開發</b>
    主站蜘蛛池模板: 国产精品自在线天天看片| 国内精品一区二区在线观看| 黄色大秀| 奇米社区| 97av视频在线播放| 毛片美女| 日本三级最新中文字幕电影 | 欧美性淫爽www视频播放| julia一区二区三区中文字幕| va国产| 欧美屁屁影院| 4hc44四虎www亚洲| 国产一区二区三区美女图片| 国产精品久久久久久久久| 欧美日韩一区二区视频图片| 欧美 日韩 中文字幕| 日韩一级欧美一级一级国产 | 免费观看片| 天天在线天天看成人免费视频| 国产精品综合色区在线观看| 欧美成人69| 四虎影裤| 久久夜夜肉肉热热日日| 午夜剧场刺激性爽免费视频| 成人精品久久| 国产成人精品曰本亚洲77美色| 精品一级毛片| 激情六月天婷婷| 蕾丝视频成人★在线观看| 欧美色频| 国产女人和拘做受视频免费| 五月婷婷爱| 1024手机最新手机在线| 2019天天操夜夜操| 日本欧美一区二区免费视| 亚洲国产一区二区在线| 亚洲精品在线视频观看| 妖精视频一区二区三区| 亚洲色图在线观看视频| 夜色福利久久久久久777777| 日本黄色的视频|