-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathULeberacao.pas
145 lines (131 loc) · 4.44 KB
/
ULeberacao.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
unit ULeberacao;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls, Mask, rxToolEdit, pngimage, Buttons, PngBitBtn,
IdCoder, IdCoder3to4, IdCoderMIME, IdBaseComponent, DateUtils, IniFiles, Registry;
type
TfrmLiberacao = class(TForm)
Panel1: TPanel;
Panel2: TPanel;
GroupBox1: TGroupBox;
GroupBox2: TGroupBox;
Image1: TImage;
txtDat_Ativacao: TDateEdit;
Label1: TLabel;
txtDat_Expiracao: TDateEdit;
Label2: TLabel;
txtRegistrado: TEdit;
Label3: TLabel;
txtControle: TEdit;
Label4: TLabel;
txtVersao: TEdit;
Label5: TLabel;
Label6: TLabel;
txtChave: TMaskEdit;
btCancelar: TPngBitBtn;
btLiberar: TPngBitBtn;
Cifra: TIdEncoderMIME;
Decifra: TIdDecoderMIME;
procedure btCancelarClick(Sender: TObject);
function ValidaRegistrp():Boolean;
procedure GravaRegistro;
procedure btLiberarClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
end;
const
Avalicao : String = 'Software\Microsoft\Windows\CurrentVersion\Explorer\EPLC\Reg';
Registro : String = '\Software\Microsoft\Windows\CurrentVersion\Explorer\EPLC\Registro';
var
frmLiberacao: TfrmLiberacao;
Arq : TIniFile;
Reg : TRegistry;
implementation
uses UFuncoes, UPrincipal;
{$R *.dfm}
procedure TfrmLiberacao.btCancelarClick(Sender: TObject);
begin
Close;
end;
procedure TfrmLiberacao.btLiberarClick(Sender: TObject);
begin
if application.MessageBox('Deseja Realmente Liberar O Sistema Agora?', 'Confirmação', MB_YesNo + MB_IconQuestion) = IdYes then begin
if ValidaRegistrp then begin
GravaRegistro;
end else begin
application.MessageBox('Chave de Ativação Inválida Verifique os Dados Digitados', 'Atenção', MB_ICONERROR);
exit;
end;
end;
end;
procedure TfrmLiberacao.FormClose(Sender: TObject; var Action: TCloseAction);
begin
application.Terminate;
end;
procedure TfrmLiberacao.FormShow(Sender: TObject);
begin
txtDat_Ativacao.Date := Date;
Reg := TRegistry.Create;
Reg.RootKey := HKEY_CURRENT_USER;
if Reg.KeyExists(Registro) then begin
Reg.OpenKey(Registro, false);
txtRegistrado.Text := Decifra.DecodeString(reg.ReadString('Registrado')) ;
end;
Reg.CloseKey;
if Length(txtRegistrado.Text) > 0 then begin
txtRegistrado.Enabled := false;
end else begin
txtRegistrado.Enabled := true;
end;
txtVersao.Text := VersaoExe;
txtControle.Text := IntToStr(Length(GetComputerNameFunc) + 135)+'.'+IntToStr(Length(txtRegistrado.Text) + 235)+'.'+IntToStr(Length(txtVersao.Text) + 195)+'.'+IntToStr(Length(txtDat_Ativacao.Text) + 395);
end;
procedure TfrmLiberacao.GravaRegistro;
begin
//Grava registro no sistema
Reg := TRegistry.Create;
Reg.RootKey := HKEY_CURRENT_USER;
if Reg.KeyExists(Registro) then begin
Reg.OpenKey(Registro, false);
Reg.WriteString('Expirar', Cifra.EncodeString(txtDat_Expiracao.Text));
Reg.WriteString('Registrado', Cifra.EncodeString(txtRegistrado.Text));
Reg.WriteString('AV', Cifra.EncodeString('1'));
Reg.CloseKey;
end else begin
Reg.OpenKey(Registro, true);
Reg.WriteString('Expirar', Cifra.EncodeString(txtDat_Expiracao.Text));
Reg.WriteString('Registrado', Cifra.EncodeString(txtRegistrado.Text));
Reg.WriteString('AV', Cifra.EncodeString('1'));
Reg.CloseKey;
end;
Application.MessageBox('Sistema Ativado Com Sucesso!!!', 'Sucesso', MB_ICONQUESTION);
Close;
end;
function TfrmLiberacao.ValidaRegistrp: Boolean;
Var
Cod1, Cod2, Cod3, Cod4, Cod5, Cod6 :Integer;
dia, mes, ano : integer;
Chave : String;
begin
dia := DayOf(txtDat_Expiracao.Date);
mes := MonthOf(txtDat_Expiracao.Date);
Ano := YearOf(txtDat_Expiracao.Date);
cod1 := ( dia * 7) + 135;
cod2 := (Length(txtRegistrado.Text) * 11) + 147;
cod3 := ((ano - 2000) * 12) + 112;
cod4 := (Length(txtVersao.Text) + 17) * 11;
cod5 := (Length(txtControle.Text) + 11) * 13;
cod6 := (mes * 9) + 135;
Chave := IntToStr(cod1) +'.'+ IntToStr(cod2) +'.'+ IntToStr(cod3) +'.'+ IntToStr(cod5) +'.'+ IntToStr(cod4) +'.'+ IntToStr(cod6);
if txtChave.Text <> Chave then begin
Result := false;
end else begin
Result := true;
end;
end;
end.