嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):78630559
本次赞助数额为: 2 元微信扫码支付:2 元
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
在原基础上增加了写入汉字,更改密码等操作,初学者,第一次写读写卡,给需要的同志
private void btnRead_Click(object sender, EventArgs e)
{
MyCtrlWord = BLOCK0_EN BLOCK1_EN BLOCK2_EN EXTERNKEY;
MyAreaNo = (byte)Convert.ToInt32(cbbSector.Text);
AuthMode = (byte)(cbbPassWordType.Text == "A密码" ? 1 : 0);//大于0表示用A密码认证,推荐用A密码认证
if (!CheckPassWord(txtPassWord.Text.Trim()))
{
return;
}
else
{
MyPiccKey=SetPassWord(txtPassWord.Text.Trim());
}
Status = piccreadex(MyCtrlWord, MyPiccSerial, MyAreaNo, AuthMode, MyPiccKey, MyPiccData);
//string CardContent = "";
//foreach (Byte temp in MyPiccData)
//{
// CardContent = CardContent System.Convert.ToString(temp, 16);
//}
txtRead.Text = ByteToString (MyPiccData );
groupBox1.Text = "读写第" cbbSector.Text "扇区 卡号:" ByteToString(MyPiccSerial);
//在下面设定断点,然后查看MyPiccSerial、MyPiccData,
//调用完 piccreadex函数可读出卡序列号到 MyPiccSerial,读出卡数据到MyPiccData,
//开发人员根据自己的需要处理MyPiccSerial、MyPiccData 中的数据了。
//处理返回函数
ShowMessage(Status);
}
private void btnWrite_Click(object sender, EventArgs e)
{
if (cbbSector.Text=="0")
{
MessageBox.Show("第0区的第0块已被固化了IC卡出厂信息,此块只能读出信息,不可更改。");
return;
}
MyAreaNo = (byte)Convert.ToInt32(cbbSector.Text);
AuthMode = (byte)(cbbPassWordType.Text == "A密码" ? 1 : 0);//大于0表示用A密码认证,推荐用A密码认证
string temp = txtWrite.Text.Trim();
temp = temp.Replace(" ", "");
txtWrite.Text = temp;
if (!CheckCardContent(temp))
{
return;
}
else
{
MyPiccData = SetCardContent(txtWrite.Text.Trim());
}
Status = piccwriteex(MyCtrlWord, MyPiccSerial, MyAreaNo, AuthMode, MyPiccKey, MyPiccData);
//处理返回函数
ShowMessage(Status);
}