在窗体的Ceate事件中加入以下代码
var re_id:integer;
reg:tregistry;
inputstr,Get_id:string;
dy_clickedok:boolean;
begin
dy:=false; //判断软件是否已到注册期标志,为FALSE则未找到
reg:=Tregistry.create;
with reg do
begin
rootkey:=HKEY_LOCAL_MACHINE;
if openkey('software\Microsoft\Windows\CurrentVersion\',true) then //建立目录,存放标志值
begin
if ValueExists('gc_id') then begin
rg_id:=readinteger('gc_id');
if (re_id<>0) and (re_id)<>100 then begin
re_id:=re_id+5;
writeinteger('gc_id',re_id);
end;
if re_id=100 then dy:=true //值已到100,则应注册
else writeinteger('gc_id',5);//建立标志,并置初始值写入注册表
end;
if dy then //若dy为真,则提示用户输入注册码
begin
clickedok:=inputquery('请输入注册码:','',inputstr);
if clickedok then begin
get_id:=inttostr(234567*2); //此值为注册码,可以改
if get_id=inputstr then begin
writeinteger('gc_id',0);//输入正确,将标志值置为0,即已注册
closekey;
free;
end;
else begin //不正确,提示并拒绝其继续使用
application.messagebox('注册码错误','',mb_ok);
closekey;
free;
application.terminate;//中止程序运行
end;
end
else begin
application.messagebox('请与作者联系,使用注册软件','',mb_ok);//若不输入注册码,提示并拒绝使用
closekey;
free;
application.terminate;
end;
end;
end;
var re_id:integer;
reg:tregistry;
inputstr,Get_id:string;
dy_clickedok:boolean;
begin
dy:=false; //判断软件是否已到注册期标志,为FALSE则未找到
reg:=Tregistry.create;
with reg do
begin
rootkey:=HKEY_LOCAL_MACHINE;
if openkey('software\Microsoft\Windows\CurrentVersion\',true) then //建立目录,存放标志值
begin
if ValueExists('gc_id') then begin
rg_id:=readinteger('gc_id');
if (re_id<>0) and (re_id)<>100 then begin
re_id:=re_id+5;
writeinteger('gc_id',re_id);
end;
if re_id=100 then dy:=true //值已到100,则应注册
else writeinteger('gc_id',5);//建立标志,并置初始值写入注册表
end;
if dy then //若dy为真,则提示用户输入注册码
begin
clickedok:=inputquery('请输入注册码:','',inputstr);
if clickedok then begin
get_id:=inttostr(234567*2); //此值为注册码,可以改
if get_id=inputstr then begin
writeinteger('gc_id',0);//输入正确,将标志值置为0,即已注册
closekey;
free;
end;
else begin //不正确,提示并拒绝其继续使用
application.messagebox('注册码错误','',mb_ok);
closekey;
free;
application.terminate;//中止程序运行
end;
end
else begin
application.messagebox('请与作者联系,使用注册软件','',mb_ok);//若不输入注册码,提示并拒绝使用
closekey;
free;
application.terminate;
end;
end;
end;
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货