📄 regobj.pas
字号:
unit RegObj;
interface
uses
Windows, Messages, SysUtils, Classes, Forms,Dialogs;
type
TRegObj = class
private
protected
procedure SetSerial; //取得主扳的序列号
procedure GetKey; //从用户序列号文件中读取序列号
function GetTimes: string; //从文件中读取程序的运行次数
function CheckKey: Boolean; //检查序列号和密码是否匹配的函数
public
expire:boolean;
FSerial: string; //主板序列号
outFSerial:string; //显示的主板序列号
FKey: string; //密码
FMaxTimes: Integer; //最大运行次数
FCompany: string; //公司名称
FEmail: string; //联系用的电子邮件
nexec:boolean; //判断其是否正常运行
constructor Create;
function Execute: Boolean; //运行对象方法
published
property Company: string read FCompany write FCompany;
property MaxTimes: Integer read FMaxTimes write FMaxTimes;
property Email: string read FEmail write FEmail;
end;
implementation
uses Ustring;
//TRegObj.
constructor TRegObj.Create;
begin
inherited;
end;
function TRegObj.GetTimes: string;
Const
//用于存储运行次数的文件,开发人员可自定义或使用注册表存储运行次数
//起此名字用于迷惑破解者,使用前不要和系统的动态链接库同名
Tmp = 'ispnet.dll';
var
datastr: string; //获取日期
Dir: array [0..255] of Char;
Fn: string;
I : Integer;
List: Tstrings;
tempstr:string;
begin
//取得Windows系统的目录
GetSystemDirectory(@Dir, 255);
For I := 0 to 255 do
begin
if Ord(Dir[I]) = 0 then Break;
Fn := Fn + Dir[I];
end;
Fn := Fn + '\' + Tmp;
try
List := TStringList.Create;
if Not FileExists(Fn) then
begin
datastr := DateTimeToStr(Now);
//存储运行首次时间
List.Text := datastr;
List.SaveToFile(Fn);
end
else
begin
List.LoadFromFile(Fn);
datastr := List.Text;
end;
Result := datastr;
finally
List.Free;
end;
end;
procedure TRegObj.SetSerial;
begin
//取得主板的序列号
FSerial := strpas(GetIdeSerialNumber);
outFSerial:=Encrypt0( FSerial);
end;
//取得密码
procedure TRegObj.GetKey;
const
Sn = 'Files\Key.dat';
var
List: TStrings;
Fn,tempstr, Path: string;
begin
Path := ExtractFilePath(Application.ExeName);
Fn := Path + Sn;
if Not FileExists(Fn) then
begin
FKey := '';
end
else
begin
try
List := TStringList.Create;
List.LoadFromFile(Fn);
tempstr:= List.Values['Key'];
FKey := DenCrypt0( tempstr);
finally
List.Free;
end;
end;
end;
function TRegObj.CheckKey: Boolean;
begin
//开发人员根据自己的需要进行修改,在这里是为了简单起见
Result := (FKey = FSerial);
end;
function TRegObj.Execute: Boolean;
const
Sn = 'Files\Key.dat';
var
Msg: string;
fdatastr:string; //record first run time
//ndatastr:string; //now run time
NewString: string; //所输入的注册码
ClickedOK: Boolean;
tempkey:string;
Fn, Path: string;
List: TStrings;
temptime:TDateTime;
begin
expire:=false;
nexec:=true;
fdatastr := GetTimes;
temptime:= StrToDateTime(fdatastr)+30;
//ndatastr:= DateTimeToStr(Now);
GetKey;
SetSerial;
if FKey = FSerial then
begin
nexec:=false;
end;
if now> temptime then
begin
expire:=true;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -