十三水半小

极光下载站 - 挨制完整的绿色硬件故乡

极光下载站

以后职位: 三水半小 技术开支 法式开支 DELPHI法式注册码设念

DELPHI法式注册码设念

工妇:2006/7/19 7:00:30 做者:佚名 人气:632

当您辛辛收奋用DELPHI做好了一个您觉得十分出有错的法式,您可可念把它宣布掀晓出去成为共享硬件呢? 做为一个共享硬件,注册码肯定是少出有了的,您能够经过历程判定法式可可注册去停止从命,工妇或一些别的限定.如古便引睹一种俭朴的注册码制制办法.思路是那样的:法式运转时先检测注册表,假定找到注册项,则表明曾经注册,假定出有找到注册项,则提示要供注册.
  <注册例程>
  正正在DELPHI下新建一工程,安排Edit1,Edit2,Label1,Label2,Button1组件.具体代码以下:

unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls,Registry;//正正在此减上Registry以便挪用注册表.
type
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
Edit2: TEdit;
Label1: TLabel;
Label2: TLabel;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
Function Check():Boolean;
Procedure CheckReg();
Procedure CreateReg();
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
PName:string; //齐局变量,寄存用户名战注册码.
PPass:integer;
implementation
{$R *.DFM}
Procedure TForm1.CreateReg();//创坐用户疑息.
var Rego:TRegistry;
begin
Rego:=TRegistry.Create;
Rego.RootKey:=HKEY_USERS;
rego.OpenKey('.DEFAULT\Software\AngelSoft\Demo',True);//键名为AngelSoft\Demo,可自止建正.
Rego.WriteString('Name',PName);//写进用户名.
Rego.WriteInteger('Pass',PPass);//写进注册码.
Rego.Free;
ShowMessage('法式曾经注册,开开!');
CheckReg; //改革.
end;
Procedure TForm1.CheckReg();//检查法式可可正正在注册表中注册.
var Rego:TRegistry;
begin
Rego:=TRegistry.Create;
Rego.RootKey:=HKEY_USERS;
IF Rego.OpenKey('.DEFAULT\Software\AngelSoft\Demo',False) then
begin
Form1.Caption:='硬件曾经注册';
Button1.Enabled:=false;
Label1.Caption:=rego.ReadString('Name');//读用户名.
Label2.Caption:=IntToStr(Rego.ReadInteger('Pass')); //读注册码.
rego.Free;
end
else Form1.Caption:='硬件已注册,请注册';
end;
Function TForm1.Check():Boolean;//检查注册码可可细确.
var
Temp:pchar;
Name:string;
c:char;
i,Long,Pass:integer;
begin
Pass:=0;
Name:=edit1.Text;
long:=length(Name);
for i:=1 to Long do
begin
temp:=pchar(copy(Name,i,1));
c:=temp^;
Pass:=Pass+ord(c); //将用户名每个字符转换为ASCII码后相减.
end;
if StrToInt(Edit2.Text)=pass then
begin
Result:=True;
PName:=Name;
PPass:=Pass;
end
else Result:=False;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
if Check then CreateReg
else ShowMessage('注册码出有细确,出法注册');
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
CheckReg;
end;
end.
<注册器>
  正正在DELPHI下新建一工程,安排Edit1,Edit2,Button1组件.具体代码以下:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
Edit2: TEdit;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
var
Temp:pchar;
Name:string;
c:char;
i,Long,Pass:integer;
begin
Pass:=0;
Name:=edit1.Text;
long:=length(Name);
for i:=1 to Long do
begin
temp:=pchar(copy(Name,i,1));
c:=temp^;
Pass:=Pass+ord(c);
end;
edit2.text:=IntToStr(pass);
end;
end.
  从<注册器>中得到注册码,便可正正在<注册例程>中停止注册.本理是操做ORD函数得到用户名每单个字符的ASCII码值,并停止相减得到注册码.
固然,那十分俭朴并破解,您能够用XOR停止同或操做,大年夜要倒与反值...具体的要看您如何真现了.总之,本文章只举一反三而已. 
<
标签
分享到:

公众号

document.write ('