我用4442型IC卡,在开卡的时候写入信息时,总是写不进去,第一次写入成功后,再也不能写入了。这是怎么回事。//有卡
st:=chk_4442(icdev); //检测是否4442卡
if st<>0 then
begin
messagebox(self.Handle,'您使用的不是本店IC卡!','提示',mb_iconinformation+mb_ok);
exit;
end;
//校验密码
if checkbox1.Checked then //新卡
password:='ffffff'
else
password:='5fd4a9'; //旧卡 st:=asc_hex(password,password1,3);
st:=csc_4442(icdev,3,password1);
if st<>0 then
begin
messagebox(self.Handle,'校验密码失败!','提示',mb_iconinformation+mb_ok);
exit;
end;
//读密码
st:=rsc_4442(icdev,3,password2);
if st<>0 then
begin
messagebox(self.Handle,'读密码失败!','提示',mb_ok+mb_iconinformation);
exit;
end;
//写密码
password:='5fd4a9';
st:=wsc_4442(icdev,3,password);
if st<>0 then
begin
messagebox(self.Handle,'写密码失败!此卡为无效卡!','提示',mb_iconinformation+mb_ok);
exit;
end;
counter:=0;
st:=rsct_4442(icdev,@counter);
if st<>0 then
begin
messagebox(self.Handle,'读计数器错误!','提示',mb_iconinformation+mb_ok);
exit;
end;
......//对数据库操作
//
//
offset:=32; //以ASC形式读 卡号地址是32
length:=9; strpcopy(data2,edit1.Text);
st:=swr_4442(icdev,offset,length,data2); //写卡号
if st<>0 then
begin
messagebox(self.Handle,'写卡号错误!','提示',mb_iconinformation+mb_ok);
exit;
end; st:=srd_4442(icdev,offset,length,data2);
if st<>0 then
begin
messagebox(self.Handle,'读卡号错误!','提示',mb_iconinformation+mb_ok);
exit;
end; //金额地址48
offset:=48;
length:=strlen(pchar(edit4.Text));
jine:=strtoint(edit4.Text);
strpcopy(data3,edit4.Text);
//写余额到卡里
st:=swr_4442(icdev,offset,length,data3);
if st<>0 then
begin
messagebox(self.Handle,'充值失败!','提示',mb_iconquestion+mb_OK);
exit;
end;
st:=srd_4442(icdev,offset,length,data3);
if st<>0 then
begin
messagebox(self.Handle,'充值失败!','提示',mb_iconquestion+mb_OK);
exit;
end; //
messagebox(self.Handle,'成功!','提示',mb_iconquestion+mb_OK);写完卡之后,再次插入IC读卡器就提示密码错误。也就是写密码没成功。但不使用strpcopy附值,而直接data2='CardNO';就可以正常使用,这是怎么回事一动态写卡就不好用
st:=chk_4442(icdev); //检测是否4442卡
if st<>0 then
begin
messagebox(self.Handle,'您使用的不是本店IC卡!','提示',mb_iconinformation+mb_ok);
exit;
end;
//校验密码
if checkbox1.Checked then //新卡
password:='ffffff'
else
password:='5fd4a9'; //旧卡 st:=asc_hex(password,password1,3);
st:=csc_4442(icdev,3,password1);
if st<>0 then
begin
messagebox(self.Handle,'校验密码失败!','提示',mb_iconinformation+mb_ok);
exit;
end;
//读密码
st:=rsc_4442(icdev,3,password2);
if st<>0 then
begin
messagebox(self.Handle,'读密码失败!','提示',mb_ok+mb_iconinformation);
exit;
end;
//写密码
password:='5fd4a9';
st:=wsc_4442(icdev,3,password);
if st<>0 then
begin
messagebox(self.Handle,'写密码失败!此卡为无效卡!','提示',mb_iconinformation+mb_ok);
exit;
end;
counter:=0;
st:=rsct_4442(icdev,@counter);
if st<>0 then
begin
messagebox(self.Handle,'读计数器错误!','提示',mb_iconinformation+mb_ok);
exit;
end;
......//对数据库操作
//
//
offset:=32; //以ASC形式读 卡号地址是32
length:=9; strpcopy(data2,edit1.Text);
st:=swr_4442(icdev,offset,length,data2); //写卡号
if st<>0 then
begin
messagebox(self.Handle,'写卡号错误!','提示',mb_iconinformation+mb_ok);
exit;
end; st:=srd_4442(icdev,offset,length,data2);
if st<>0 then
begin
messagebox(self.Handle,'读卡号错误!','提示',mb_iconinformation+mb_ok);
exit;
end; //金额地址48
offset:=48;
length:=strlen(pchar(edit4.Text));
jine:=strtoint(edit4.Text);
strpcopy(data3,edit4.Text);
//写余额到卡里
st:=swr_4442(icdev,offset,length,data3);
if st<>0 then
begin
messagebox(self.Handle,'充值失败!','提示',mb_iconquestion+mb_OK);
exit;
end;
st:=srd_4442(icdev,offset,length,data3);
if st<>0 then
begin
messagebox(self.Handle,'充值失败!','提示',mb_iconquestion+mb_OK);
exit;
end; //
messagebox(self.Handle,'成功!','提示',mb_iconquestion+mb_OK);写完卡之后,再次插入IC读卡器就提示密码错误。也就是写密码没成功。但不使用strpcopy附值,而直接data2='CardNO';就可以正常使用,这是怎么回事一动态写卡就不好用
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货