📄 licenseform.pas
字号:
unit LicenseForm;
interface
uses Windows, SysUtils, Classes, Graphics, Forms, Controls, StdCtrls,
Buttons, ExtCtrls, IniFiles, Dialogs;
type
TfrmLicense = class(TForm)
Panel1: TPanel;
ProgramIcon: TImage;
lblProductName: TLabel;
lblVersion: TLabel;
btnOK: TButton;
lblCompanyName: TLabel;
lblRegistered: TLabel;
lblTrademark: TLabel;
btnCancel: TButton;
editRegisteredTo: TEdit;
editRegistrationCode: TEdit;
Label1: TLabel;
Label2: TLabel;
procedure FormShow(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure btnOKClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
frmLicense: TfrmLicense;
implementation
uses BS1Form;
{$R *.DFM}
procedure TfrmLicense.FormShow(Sender: TObject);
begin
if License = '' then begin
editRegisteredTo.text := '';
editRegisteredTo.readonly := false;
end else begin
editRegisteredTo.text := RegisteredTo;
//editRegisteredTo.readonly := true; //Since some copies go out "registered" with no name, suppress "read-only" to prevent them thinking this is a bug. Would prefer them to get stuck on the code instead.
//editRegistrationCode.setfocus;
if RegisteredTo <> '' then begin
editRegisteredTo.readonly := true;
editRegistrationCode.setfocus;
end;
end;
end;
procedure TfrmLicense.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Action := caFree;
end;
procedure TfrmLicense.btnOKClick(Sender: TObject);
var
UsersIni: TIniFile;
RegisteredTo1, RegisteredTo3, LicenseSuffix: string;
begin
if editRegisteredTo.text = '' then begin
editRegisteredTo.setfocus;
raise(exception.create('Company name must be entered'));
end;
RegisteredTo1 := Copy(editRegisteredTo.text, 1, 1);
RegisteredTo3 := Copy(editRegisteredTo.text, 3, 1);
if UpperCase(RegisteredTo3) = 'A' then LicenseSuffix := '1'
else if UpperCase(RegisteredTo3) = 'B' then LicenseSuffix := '2'
else if UpperCase(RegisteredTo3) = 'C' then LicenseSuffix := '3'
else if UpperCase(RegisteredTo3) = 'D' then LicenseSuffix := '4'
else if UpperCase(RegisteredTo3) = 'E' then LicenseSuffix := '5'
else if UpperCase(RegisteredTo3) = 'F' then LicenseSuffix := '6'
else if UpperCase(RegisteredTo3) = 'G' then LicenseSuffix := '7'
else if UpperCase(RegisteredTo3) = 'H' then LicenseSuffix := '8'
else if UpperCase(RegisteredTo3) = 'I' then LicenseSuffix := '9'
else if UpperCase(RegisteredTo3) = 'J' then LicenseSuffix := '0'
else if UpperCase(RegisteredTo3) = 'K' then LicenseSuffix := '1'
else if UpperCase(RegisteredTo3) = 'L' then LicenseSuffix := '2'
else if UpperCase(RegisteredTo3) = 'M' then LicenseSuffix := '3'
else if UpperCase(RegisteredTo3) = 'N' then LicenseSuffix := '4'
else if UpperCase(RegisteredTo3) = 'O' then LicenseSuffix := '5'
else if UpperCase(RegisteredTo3) = 'P' then LicenseSuffix := '6'
else if UpperCase(RegisteredTo3) = 'Q' then LicenseSuffix := '7'
else if UpperCase(RegisteredTo3) = 'R' then LicenseSuffix := '8'
else if UpperCase(RegisteredTo3) = 'S' then LicenseSuffix := '9'
else if UpperCase(RegisteredTo3) = 'T' then LicenseSuffix := '0'
else if UpperCase(RegisteredTo3) = 'U' then LicenseSuffix := '1'
else if UpperCase(RegisteredTo3) = 'V' then LicenseSuffix := '2'
else if UpperCase(RegisteredTo3) = 'W' then LicenseSuffix := '3'
else if UpperCase(RegisteredTo3) = 'X' then LicenseSuffix := '4'
else if UpperCase(RegisteredTo3) = 'Y' then LicenseSuffix := '5'
else if UpperCase(RegisteredTo3) = 'Z' then LicenseSuffix := '6'
else LicenseSuffix := '7';
if UpperCase(RegisteredTo1) = 'A' then LicenseSuffix := LicenseSuffix + '1'
else if UpperCase(RegisteredTo1) = 'B' then LicenseSuffix := LicenseSuffix + '2'
else if UpperCase(RegisteredTo1) = 'C' then LicenseSuffix := LicenseSuffix + '3'
else if UpperCase(RegisteredTo1) = 'D' then LicenseSuffix := LicenseSuffix + '4'
else if UpperCase(RegisteredTo1) = 'E' then LicenseSuffix := LicenseSuffix + '5'
else if UpperCase(RegisteredTo1) = 'F' then LicenseSuffix := LicenseSuffix + '6'
else if UpperCase(RegisteredTo1) = 'G' then LicenseSuffix := LicenseSuffix + '7'
else if UpperCase(RegisteredTo1) = 'H' then LicenseSuffix := LicenseSuffix + '8'
else if UpperCase(RegisteredTo1) = 'I' then LicenseSuffix := LicenseSuffix + '9'
else if UpperCase(RegisteredTo1) = 'J' then LicenseSuffix := LicenseSuffix + '0'
else if UpperCase(RegisteredTo1) = 'K' then LicenseSuffix := LicenseSuffix + '1'
else if UpperCase(RegisteredTo1) = 'L' then LicenseSuffix := LicenseSuffix + '2'
else if UpperCase(RegisteredTo1) = 'M' then LicenseSuffix := LicenseSuffix + '3'
else if UpperCase(RegisteredTo1) = 'N' then LicenseSuffix := LicenseSuffix + '4'
else if UpperCase(RegisteredTo1) = 'O' then LicenseSuffix := LicenseSuffix + '5'
else if UpperCase(RegisteredTo1) = 'P' then LicenseSuffix := LicenseSuffix + '6'
else if UpperCase(RegisteredTo1) = 'Q' then LicenseSuffix := LicenseSuffix + '7'
else if UpperCase(RegisteredTo1) = 'R' then LicenseSuffix := LicenseSuffix + '8'
else if UpperCase(RegisteredTo1) = 'S' then LicenseSuffix := LicenseSuffix + '9'
else if UpperCase(RegisteredTo1) = 'T' then LicenseSuffix := LicenseSuffix + '0'
else if UpperCase(RegisteredTo1) = 'U' then LicenseSuffix := LicenseSuffix + '1'
else if UpperCase(RegisteredTo1) = 'V' then LicenseSuffix := LicenseSuffix + '2'
else if UpperCase(RegisteredTo1) = 'W' then LicenseSuffix := LicenseSuffix + '3'
else if UpperCase(RegisteredTo1) = 'X' then LicenseSuffix := LicenseSuffix + '4'
else if UpperCase(RegisteredTo1) = 'Y' then LicenseSuffix := LicenseSuffix + '5'
else if UpperCase(RegisteredTo1) = 'Z' then LicenseSuffix := LicenseSuffix + '6'
else LicenseSuffix := LicenseSuffix + '7';
//ShowMessage(LicenseSuffix);
if editRegistrationCode.text = 'b935k4' + LicenseSuffix then begin License := 'b935k4'; MaxUsers := 1;
end else if editRegistrationCode.text = 'b935k4' + '111' then begin License := 'b935k4'; MaxUsers := 1; //Code not based on name: if trust the customer.
//end else if editRegistrationCode.text = 'a9tr24' + LicenseSuffix then begin License := 'a9tr24'; MaxUsers := 2;
end else if editRegistrationCode.text = 'c9kk42' + LicenseSuffix then begin License := 'c9kk42'; MaxUsers := 999;
end else if editRegistrationCode.text = 'c9kk42' + '111' then begin License := 'c9kk42'; MaxUsers := 999; //Code not based on name: if trust the customer.
//end else if editRegistrationCode.text = 'a3ab6y' + LicenseSuffix then begin License := 'a3ab6y'; MaxUsers := 4;
//end else if editRegistrationCode.text = '285rer' + LicenseSuffix then begin License := '285rer'; MaxUsers := 5;
//end else if editRegistrationCode.text = '298bb3' + LicenseSuffix then begin License := '298bb3'; MaxUsers := 6;
//end else if editRegistrationCode.text = '298bb3' + '111' then begin License := '298bb3'; MaxUsers := 6; //Code not based on name: if trust the customer.
//end else if editRegistrationCode.text = 'k2w6tt' + LicenseSuffix then begin License := 'k2w6tt'; MaxUsers := 7;
//end else if editRegistrationCode.text = '2h9gt5' + LicenseSuffix then begin License := '2h9gt5'; MaxUsers := 8;
//end else if editRegistrationCode.text = '9j5att' + LicenseSuffix then begin License := '9j5att'; MaxUsers := 9;
//end else if editRegistrationCode.text = 'f25xfs' + LicenseSuffix then begin License := 'f25xfs'; MaxUsers := 10;
end else begin
editRegistrationCode.setfocus;
raise(exception.create('Registration code is invalid'));
end;
UsersIni := TIniFile.Create(strDatabaseName + '\Users.ini');
UsersIni.WriteString('General', 'RegisteredTo', editRegisteredTo.text);
UsersIni.WriteString('General', 'License', License);
UsersIni.Free;
RegisteredTo := editRegisteredTo.text;
License := editRegistrationCode.text;
ModalResult := mrOK;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -