先将密码存入注册表;把记数变量number设为全局变量。这样一来可
使其初始化时为0。
procedure tpasswordform.buttonokclick(sender:tobject);
var passwordregistry:tregistry
passwordstr:string;
begin
passwordregistry:=我的电脑/hkey_current_config/password;{假设密码存放在这里}
passwordregistry.opekey('',false);{打开此分枝}
passwordstr:=passwordregistry.readstring('mypassword');{password下有一个主键,
密码就放在mypassword
主键下}
if editpasswrlogin.text<>passwordstr then
begin
inc(number);
if number=3 then application.terminate;
end
else passwordform.modalresult:=1;
end;
最后修改项目文件:
......
begin
formpassword:=tformpassword.create(application);
if formpassword.modalresult=1 then
begin
application.createform(tform1,form1);
.......
.......
application.run
end
else showmessage('密码错误,请重新输入');
完了,啊!用了好多好多时间!你一定要给我分分喔!