读写卡测试程序c#2003源代码

读写卡测试程序c#2003源代码   界面图

 

 

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Runtime.InteropServices;  //调用动态库一定要加入这个引用
using System.Text;//一定要加入这个

//广州荣士电子有限公司,联系电话020-82318861,82322852,定制13826029618 网址http://www.icmcu.com

namespace iccardreader
{
 /// <summary>
 /// Form1 的摘要说明。
 /// </summary>
 public class Form1 : System.Windows.Forms.Form
 {
  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.Label label1;
  /// <summary>
  /// 必需的设计器变量。
  //常量定义
  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;
  private System.Windows.Forms.TextBox textBox1;
  private System.Windows.Forms.Button button6;
  private System.Windows.Forms.Button button7;
  private System.Windows.Forms.Button button8;
  private System.Windows.Forms.TextBox textBox2;//用函数参数中的密码组进行读写卡时的认证,而不是用藏于读写器的芯片内的密码来认证。
  public const byte NEEDHALT = 0x20;//读卡或写卡后顺便休眠该卡,休眠后,卡必须拿离开感应区,再放回感应区,才能进行第二次操作。


  //------------------------------------------------------------------------------------------------------------------------------------------------------
  //外部函数声明:让设备发出声响
  [DllImport("OUR_MIFARE.dll", EntryPoint = "pcdbeep")]
  static extern byte pcdbeep(ulong xms);//xms单位为毫秒

  //------------------------------------------------------------------------------------------------------------------------------------------------------   
  //读取设备编号,可做为软件加密狗用,也可以根据此编号在公司网站上查询保修期限
  [DllImport("OUR_MIFARE.dll", EntryPoint = "pcdgetdevicenumber")]
  static extern byte pcdgetdevicenumber(byte[] devicenumber);//devicenumber用于返回编号


  //------------------------------------------------------------------------------------------------------------------------------------------------------
  //轻松读卡
  [DllImport("OUR_MIFARE.dll", EntryPoint = "piccreadex")]
  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")]
  static extern byte piccwriteex(byte ctrlword, byte[] serial, byte area, byte keyA1B0, byte[] picckey, byte[] piccdata0_2);
  //参数:说明
  //ctrlword:控制字
  //serial:卡序列号数组,用于指定或返回卡序列号
  //are

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值