Delphi-用Delphi实现软件注册功能
(2014-10-20 22:19:35)
标签:
itdelphi软件注册收费 |
分类: delphi高级应用 |
一个button 一个edit 三个label 一个timer
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes,
Graphics, Controls, Forms,
Dialogs, StdCtrls, Registry, ExtCtrls;
type
TForm1 = class(TForm)
Edit1: TEdit;
Button1: TButton;
Label1: TLabel;
Label2: TLabel;
Timer1: TTimer;
Label3: TLabel;
procedure FormCreate(Sender:
TObject);
procedure
Button1Click(Sender: TObject);
procedure Timer1Timer(Sender:
TObject);
private
{ Private declarations
}
public
{ Public declarations }
end;
var
Form1: TForm1;
ltime:integer;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
var
re_id:integer;
registerTemp:TRegistry;
inputstr,get_id:String;
dy,clickedok:boolean;
begin
ltime:=30;
label3.Caption:='';
dy:=False;
registerTemp:=TRegistry.Create;
with registerTemp do
begin
Rootkey:=HKEY_LOCAL_MACHINE;
if
OpenKey('Software\Microsoft\Windows\CurrentVersion\Mark',True)
then
begin
if
RegisterTemp.ValueExists('gc_id') then
begin
re_id:=readinteger('gc_id');
if(re_id<>0) and (re_id<>20)
then
begin
re_id:=re_id+1;
label2.Caption:='还剩下'+inttostr(20-re_id)+'次
';
registerTemp.WriteInteger('gc_id',re_id);
end
else
begin
label2.Caption:='已注册版本 ';
edit1.Visible:=False;
button1.Visible:=False;
label1.Visible:=False;
Timer1.Enabled:=False;
label3.Visible:=False;
end;
if re_id=20 then
dy:=true;
end
else RegisterTemp.WriteInteger('gc_id',1);
end;
if dy
then
begin
clickedok:=InputQuery('您使用的是非注册软件,请输入注册码:','',inputstr);
if
clickedok then
begin
get_id:=inttostr(123456);
if get_id=inputstr then
begin
registerTemp.WriteInteger('gc_id',0);
application.MessageBox('恭喜注册成功','恭喜',MB_OK);
RegisterTemp.CloseKey;
RegisterTemp.Free;
form1.Close;
end
else
begin
application.MessageBox('您输入的注册码不正确','提示',MB_OK);
RegisterTemp.CloseKey;
RegisterTemp.Free;
application.Terminate;
unit Unit1;
interface
uses
type
var
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
var
re_id:integer;
registerTemp:TRegistry;
inputstr,get_id:String;
dy,clickedok:boolean;
begin
ltime:=30;
label3.Caption:='';
dy:=False;
registerTemp:=TRegistry.Create;
with registerTemp do