⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 regobj.~pa

📁 通用人力资源系统,分类可以自设定 可以熟练掌握DELPHI语言
💻 ~PA
字号:
unit RegObj;

interface

uses
  Windows, rlzy_main_unit, Messages, SysUtils, Classes, Forms, sysifo, Dialogs, rl_yhzc_unit;

type
  TRegObj = class
  private
    FSerial: string; //主板序列号
    FKey: string; //密码
    FMaxTimes: Integer; //最大运行次数
    FCompany: string; //公司名称
    FEmail: string; //联系用的电子邮件
  protected
    procedure SetSerial; //取得主扳的序列号
    procedure GetKey; //从用户序列号文件中读取序列号
    function GetTimes: Integer; //从文件中读取程序的运行次数
    function CheckKey: Boolean; //检查序列号和密码是否匹配的函数
  public

    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

//TRegObj.

constructor TRegObj.Create;
begin
  inherited;
end;

function TRegObj.GetTimes: Integer;
const
//用于存储运行次数的文件,开发人员可自定义或使用注册表存储运行次数
//起此名字用于迷惑破解者,使用前不要和系统的动态链接库同名
  Tmp = 'winsysnet.dll';
var
  Ch: Char;
  Dir: array[0..255] of Char;
  Fn: string;
  I: Integer;
  List: Tstrings;
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
      Ch := Chr(1)
    else
    begin
      List.LoadFromFile(Fn);
      Ch := List.Text[1];
      Ch := Chr(Ord(Ch) + 1);
    end;
    List.Text := Ch;
//存储运行次数
    List.SaveToFile(Fn);
    Result := Ord(Ch);
  finally
    List.Free;
  end;
end;

procedure TRegObj.SetSerial;
var
  aa: array[1..10] of char;
  i, j, cd, sjcd: integer;
  zfc, zc, yzm: string;
begin
  j := 1;
  zfc := '';
  yzm := '';
  cd := strlen(GetIdeSerialNumber);
  sjcd := strlen(pchar(trim(GetIdeSerialNumber)));
  if sjcd < cd then
    for i := 1 to cd - sjcd do
    begin
      zfc := zfc + chr(64 + i + j);
      j := j + 3;
      if 64 + i + j > 90 then
        j := 1;
    end;
  zc := uppercase(zfc + trim(GetIdeSerialNumber));
{
for i:=1 to cd do
begin
YZM:=YZM+inttostr(trunc(ord(zc[i])/9));
end;
}
  FSerial := zc;
//取得硬盘的序列号
end;

//取得密码

procedure TRegObj.GetKey;
const
  Sn = 'Key.dat';
var
  List: TStrings;
  Fn, Path: string;
begin
  Path := ExtractFilePath(Application.ExeName);
  Fn := Path + Sn;
  if not FileExists(Fn) then
  begin
    FKey := '';
    Exit;
  end;
  try
    List := TStringList.Create;
    List.LoadFromFile(Fn);
    FKey := trim(list.Strings[0]);
//application.MessageBox(pchar(fkey), '用户信息', Mb_Ok + Mb_IconWarning);
  finally
    List.Free;
  end;
end;

function TRegObj.CheckKey: Boolean;
var
  yzm: string;
  i, cd: integer;
begin
  yzm := '';
  cd := strlen(pchar(fserial));
//开发人员根据自己的需要进行修改,在这里是为了简单起见
  for i := 1 to cd do
  begin
    YZM := YZM + inttostr(trunc(ord(FSerial[i]) / 9));
  end;
  Result := FKey = yzm;
end;

function TRegObj.Execute: Boolean;
var
  Msg, yzm: string;
  T, cd, i: Integer;
begin
  T := GetTimes;
  GetKey;
  SetSerial;
  yzm := '';
  cd := strlen(pchar(fserial));
  for i := 1 to cd do
  begin
    YZM := YZM + inttostr(trunc(ord(FSerial[i]) / 9));
  end;
  if FKey <> yzm then
  begin
    zhuce := 0;
    Msg := ' 您这是第' + IntToStr(T) + '次运行此程序(最大次数:' + IntToStr(FMaxTimes) +
      ')!';
    Application.MessageBox(PChar(Msg), '用户信息', Mb_Ok + Mb_IconWarning);
    Msg := '欢迎使用' + Company + '的软件,如果您觉得满意的话,请注册或购买正版软件!';
    Application.MessageBox(PChar(Msg), '建议', Mb_Ok + Mb_IconInformation);
    if T > FMaxTimes then
    begin
      if Application.MessageBox(' 是否注册?', '注册', Mb_YesNo + Mb_IconQuestion) =
        Id_Yes then
      begin
        Msg := '您的注册号是:"' + FSerial + '"' + Chr(13) + Chr(10) +
          '请您将以上序列号通过电子邮件寄给以下信箱:' + FEmail;
        Application.MessageBox(PChar(Msg), '软件 注册', Mb_Ok + Mb_Iconinformation);
      end;
      Application.Terminate;
    end;
  end
  else
    zhuce := 1;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -