要做一个自动读取卡信息的程序,需要一个Timer每1秒寻一次卡,同样的一段代码 放到一个按钮事件中可以正常执行,放到timer事件中提示内存错误,是不是有什么东西没有释放掉procedure TfrmEmpM1.Timer1Timer(Sender: TObject);
var st,Snr,pst:Integer;
CardNo,Init,Amt,Sta,Pass,Data:String;
databuff:Array[0..15]of Char;
begin
showmessage('请插卡');
rf_halt(icdev);
st:=rf_card(icdev,0,Snr); //寻卡
if st=0 then begin
rf_beep(icdev,10);
pass:=chr($ff)+chr($ff)+chr($ff)+chr($ff)+chr($ff)+chr($ff);
if rf_load_key_Hex(icdev,0,0,pass)=0 then
pst:=rf_authentication(icdev,0,0); //比较卡密码
if st=pst then begin
st:=rf_read(icdev,1,@databuff); //读卡
Label1.Caption:=databuff;
rf_beep(icdev,10);
end;
end;
end;
var st,Snr,pst:Integer;
CardNo,Init,Amt,Sta,Pass,Data:String;
databuff:Array[0..15]of Char;
begin
showmessage('请插卡');
rf_halt(icdev);
st:=rf_card(icdev,0,Snr); //寻卡
if st=0 then begin
rf_beep(icdev,10);
pass:=chr($ff)+chr($ff)+chr($ff)+chr($ff)+chr($ff)+chr($ff);
if rf_load_key_Hex(icdev,0,0,pass)=0 then
pst:=rf_authentication(icdev,0,0); //比较卡密码
if st=pst then begin
st:=rf_read(icdev,1,@databuff); //读卡
Label1.Caption:=databuff;
rf_beep(icdev,10);
end;
end;
end;
解决方案 »
- 怪事!!recv的时候,写入buffer的数据少于recv返回的字节数,甚至buffer是空的!!!!
- 如何检测鼠标和键盘的类型(解决者给100分)
- 怎么在没有安装delphi和fr的机器上运行fr开发的报表程序?
- 字符串截取替换问题!在线等,立马结分!
- 关于Picklist的问题。
- SQL语句select好象可以嵌套,怎么用法?
- DBGrid ???
- 救命!!托普软件做开发薪水如何?使用期一般多长?使用期工资一般为多少????
- 高手们!一个关于ComboBox简单的问题。请进吧!!!
- 难道真的没有人愿意看一下了吗?5555555555
- 关于datamoudle的links问题
- Access并发问题
Access violation at Address100020f2 in module 'mwfr32.dll'.Write or address 0000013
st:=rf_card(icdev,0,Snr); //寻卡
应该是资源释放问题;
另外你可以把执行时间间隔加长,再看是否会出错,如果出错则一定是dll 的资源释放问题;
begin
Timer1.Enable := False;... ... Timer1.Enable := True;
end;