//------------------------------------------------------------------------------
//
// 1. inline scharf machen!
// 2 Quersumme scharf machen
//
//------------------------------------------------------------------------------
unit Lizenz;
//------------------------------------------------------------------------------
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Strutils,
Dialogs, OptionClass, DateUtils, Utilities, UtilitiesOwn, StdCtrls, ClipBrd, DBAccess;
//-------------------------------------------------------
// Constants
//-------------------------------------------------------
const
em=15000;
Codelength=64;
MySQLlength=8;
//------------------------------------------------------------------------------
type
TAktivform = class(TForm)
Edit1: TEdit;
Label1: TLabel;
Label2: TLabel;
Edit2: TEdit;
Button1: TButton;
Button2: TButton;
procedure Form1DruckenExecute(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure AktivierenviaInternet();
procedure AktivierenviaCode();
procedure AktivierenGetWinProdId();
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
goon:boolean;
end;
//------------------------------------------------------------------------------
var
Aktivform: TAktivform;
name:String;
code:String;
//------------------------------------------------------------------------------
procedure checkedition(); //inline;
procedure checklicense(); //inline;
procedure checklicensesum(); //inline;
procedure setlicensesum(); //inline;
procedure setlicenseMachineId(Winid:String); // inline
procedure checknetwork(); //inline;
procedure TrytoActivate(goon:boolean);
//------------------------------------------------------------------------------
implementation
uses OptionClassGen;
{$R *.dfm}
//------------------------------------------------------------------------------
//
// check license sum
//
//------------------------------------------------------------------------------
procedure checklicensesum();
var ll1:integer;
begin
ll1:=Opt.OptSum();
if (Opt.R.CheckSum<>0) and (Opt.R.CheckSum<>ll1) then begin
Opt.R.Activated:=false;
error(em+53,'Lizenz abgelaufen');
ExitProcess(91);
end;
RandSeed:=GetCurrentTime;
end;
//------------------------------------------------------------------------------
//
// set machine id
//
//------------------------------------------------------------------------------
procedure setlicenseMachineId(Winid:String);
//var ll1:integer;
begin
Opt.R.WindowsProductId:=WinId;
end;
//------------------------------------------------------------------------------
//
// check license sum
//
//------------------------------------------------------------------------------
procedure setlicensesum();
var ll1:integer;
begin
ll1:=Opt.OptSum();
Opt.R.CheckSum:=ll1
end;
//------------------------------------------------------------------------------
//
// check for network fake
//
//------------------------------------------------------------------------------
procedure checknetwork();
var ip:String;
begin
ip:=getIP('cococo.de');
if ip<>'0' then
if ip<>'87.230.16.129' then
Opt.R.Activated:=false;
end;
//------------------------------------------------------------------------------
//
// check license
//
//------------------------------------------------------------------------------
procedure checklicense();
begin
if (GetWinProductId<>Opt.R.WindowsProductId) or (Opt.R.LastUse>Today) then begin
Opt.R.Activated := false;
Opt.R.Edition:=Standard;
if not Lizenzmeldung then begin
error(em+54,'Die Software funktioniert erst nach Lizensierung und Registrierung!');
Lizenzmeldung:=true
end
end;
if (Opt.R.DaysUsed>EvaluationPeriod) and Not Opt.R.Activated then begin
error(em+55,'Lizenz abgelaufen');
TrytoActivate(false);
end;
// check after 120 days (like Windows does)
if (Opt.R.DaysUsed>LicenseCheckTwo) then begin
If (GetWinProductId<>Opt.R.WindowsProductId) then begin
error(em+63,'Lizenz abgelaufen');
TrytoActivate(false);
end;
end;
//-------- test code für activate ---------
//
//TrytoActivate(false);
//
//-----------------------------------------
end;
//------------------------------------------------------------------------------
//
// check edition
//
//------------------------------------------------------------------------------
procedure checkedition();
begin
if Opt.R.Edition>=Enterprise then begin
Opt.R.Activated := true;
Opt.R.Edition := Enterprise;
Opt.R.WindowsProductId := GetWinProductId;
end;
end;
//------------------------------------------------------------------------------
//
// activate via Internet
//
//------------------------------------------------------------------------------
procedure TAktivform.AktivierenviaInternet();
var Prod:String;Edit:String;E:Editions;
begin
SQLSelect(Code,Prod,Edit);
if prod=Application.Title then begin
for E:=low(Editions) to High(Editions) do
if EditionStrings[E]=Edit then begin
Opt.R.Edition:=E;
Opt.r.Activated:=true;
Opt.R.CheckSum:=Opt.OptSum();
Opt.PutOptions(PChar(Optionsfilename(Application.Title)));
ShowMessage('Bitte neu starten');
Opt.R.SecretKey := SetSecretRegistryValue(Installkey,0,Productnumber);
Opt.R.SecretKey := SetSecretFile(InstallKey,0,Productnumber);
end;
SQLUpdate(Code,GetWinProductId,'IP',getCPUID,getDiskId(GetCurrentdir()),'');
ExitProcess(0);
end else
ExitProcess(99);
end;
//------------------------------------------------------------------------------
//
// activate via Internet
//
//------------------------------------------------------------------------------
procedure TAktivform.AktivierenGetWinProdId();
var Inp,Erg,Key:array [0..64] of Char;
Pin,Pout,Pkey:PChar;C3,Edit:String;
begin
strpcopy(Key,'abcdefgh'); // secret key
Pin:=@Inp;Pout:=@erg;PKey:=@Key;
// code to get winprodid
Edit:=EditionStrings[Standard];
C3:=GetWinProductId()+'-'+Edit;
if Length(C3)>Codelength then error(em+57,'Code zu lang!');
while Length(C3)<Codelength do C3:=C3+' ';
strpcopy(Pout,'');StrPCopy(Pin,PChar(C3));
Opt.DoActivate(Pin,Pout,PKey);
strpcopy(Pin,'');
Opt.DoActivate(Pin,Pout,PKey);
Clipboard.SetTextBuf(Pout);
ShowMessage('Code '+crlf+crlf+'"'+Pout+'"'+crlf+crlf+' ist in der Zwischeanablage');
end;
//------------------------------------------------------------------------------
//
// activate via Internet
//
//------------------------------------------------------------------------------
procedure TAktivform.AktivierenviaCode();
var Inp,Erg,Win,Key:array [0..64] of Char;E:Editions;
Pin,Pout,Pwin,Pkey:PChar;C1,C2,Edit:String;i:integer;
begin
strpcopy(Key,'abcdefgh'); // secret key
Pin:=@Inp;Pout:=@erg;PKey:=@Key;PWin:=@win;
// now decode Code
strpcopy(Pin,'');StrPCopy(Pout,PChar(Code));
Opt.DoActivate(Pin,Pout,PKey);
strpcopy(PWin,GetWinProductId());
C1:=PWin;C2:=Trim(Pin);
i:=length(C2);while C2[i] in ['a'..'z','A'..'Z','0'..'9'] do i:=i-1;
Edit:=MidStr(C2,i+1,Length(C2)-i);C2:=MidStr(C2,1,i-1);
if C1=C2 then begin
for E:=low(Editions) to High(Editions) do
if EditionStrings[E]=Edit then begin
Opt.R.Edition:=Standard;
Opt.R.Activated:=true;
Opt.R.CheckSum:=Opt.OptSum();
Opt.PutOptions(PChar(Optionsfilename(Application.Title)));
ShowMessage('Bitte neu starten');
Opt.R.SecretKey := SetSecretRegistryValue(Installkey,0,Productnumber);
Opt.R.SecretKey := SetSecretFile(InstallKey,0,Productnumber);
ExitProcess(0);
end;
end;
end;
//------------------------------------------------------------------------------
//
// check edition
//
//------------------------------------------------------------------------------
procedure TrytoActivate(goon:boolean);
begin
Aktivform := TAktivform.Create(nil);
dostop:=not goon;
Aktivform.ShowModal;
end;
//------------------------------------------------------------------------------
//
// check edition
//
//------------------------------------------------------------------------------
procedure TAktivform.Button1Click(Sender: TObject);
begin
Name:=Edit1.Text;
Code:=Edit2.Text;
// code to get winprodid
//AktivierenGetWinProdId();
if length(code)<=MySQLlength then AktivierenviaInternet()
else AktivierenviaCode();
end;
//------------------------------------------------------------------------------
//
// check edition
//
//------------------------------------------------------------------------------
procedure TAktivform.Button2Click(Sender: TObject);
begin
Close;
if dostop then ExitProcess(0);
end;
procedure TAktivform.Form1DruckenExecute(Sender: TObject);
begin
end;
{------------------------------------------------------------------}
{- -}
{- Ende dieser Quelle -}
{- -}
{------------------------------------------------------------------}
end.
¤ Dauer der Verarbeitung: 0.29 Sekunden
(vorverarbeitet)
¤
|
Haftungshinweis
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.
|