Add online activation to your application

This is the poor man’s solution to feature  online activation in your application.

Recipe ingredients:
Delphi
OnGuard Components (Free, Open Source). https://github.com/TurboPack/OnGuard-FMX
Post Component  (TMS TWebPost, Indy HTTP Post or similar components). https://www.tmssoftware.com/site/webpost.asp
PHP and MySQL Server.

Cooking Directions:
You can get OnGuard for Firemonkey here https://github.com/TurboPack/OnGuard-FMX instructional video https://www.youtube.com/watch?v=uyW_w_2ZC8M
TMS TWebPost https://www.tmssoftware.com/site/webpost.asp

On our form’s above our implementation section we add a global variable and the constant key that was generated by OnGuard as shown in the video.

//Code Snip

var
Form1: TForm1;
UNLOCKME : Boolean;
  const
CKey : TKey = ($E5,$SF,$94,$F4,$72,$C8,$A5,$D8,$8A,$FA,$6F,$7C,$AB,$FC,$E5,$8R);
procedure TForm1.FormActivate(Sender: TObject);
begin
if UNLOCKEME = false then
Begin
Form2.Show;
End;
end;

 

procedure TForm1.OgSerialNumberCode1Checked(Sender: TObject;
Status: TCodeStatus);
begin
case Status of
ogValidCode    : Begin
UNLOCKEME := TRUE;
End;
    ogInvalidCode  :  Begin
UNLOCKEME := FALSE;
End;
end;
end;
procedure TForm1.OgSerialNumberCode1GetCode(Sender: TObject; var Code: TCode);
var
S
begin
HexToBuffer(S, Code, SizeOf(Code));
end;

procedure TForm1.OgSerialNumberCode1GetKey(Sender: TObject; var Key: TKey);
begin
Key := CKey;
end;

 

Form2

procedure TForm2.Button1Click(Sender: TObject);
begin
if UNLOCKEME = false then
Begin
Form1.OgSerialNumberCode1.CheckCode(True);
if Form1.OgSerialNumberCode1.IsCodeValid then
ShowMessage(‘Invalid Key’);
end;
End;
if UNLOCKEME = True then
Form2.Close;
end;
procedure TForm2.Button2Click(Sender: TObject);
var
wpi:twebpostitem;
s1, machine: String;
Key128: TKey128;
begin
webpost1.items.Clear;
if Edit1.Text <> ” then
begin
 with webpost1.items do
begin
wpi:=add;
wpi.name:=’email’;
wpi.value:= Edit1.Text;
end;
 if webpost1.execute then
begin
s1 := webpost1.PostResult;
if s1 <> ‘1’ then
Begin
if UNLOCKEME= false then
Begin
Form1.OgSerialNumberCode1.CheckCode(True);
if Form1.OgSerialNumberCode1.IsCodeValid then begin
Form2.Close;
ShowMessage(‘Activated ‘);
end Else  ShowMessage(‘Could not connect to server’);
Exit;
end;
End;
if UNLOCKEME = True then
Form2.Close;
end;
end;
end;
end;
Then you will need a PHP script  to post your request for the activation Key.
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s