products/Sources/formale Sprachen/Delphi/Elbe 1.0/Sources image not shown  

Quellcode-Bibliothek

© Kompilation durch diese Firma

[Weder Korrektheit noch Funktionsfähigkeit der Software werden zugesichert.]

Datei: Lizenz.pas   Sprache: Delphi

//------------------------------------------------------------------------------
//
//1. inline scharf machen!
//2 Quersumme scharf machen
//
//------------------------------------------------------------------------------
unit Lizenz;
//------------------------------------------------------------------------------
interface
Uses
  //-------------------------------------------------------
  //local
  //-------------------------------------------------------
  GenDefs,OptionClass,Utilities,Language,OwnUtils,Splash,
  //-------------------------------------------------------
  //global
  //-------------------------------------------------------
  Forms,StdCtrls,Controls,Classes,DateUtils,Windows;
//-------------------------------------------------------
//Constants
//-------------------------------------------------------
const
  Codelength=64;
  MySQLlength=8;
  //------------------------------------------------------------------------------
type
  TLizenzForm= class(TForm)
    Edit1:TEdit;
    Label1:TLabel;
    Label2:TLabel;
    Edit2:TEdit;
    Button1:TButton;
    Button2:TButton;
    Button3:TButton;
    procedure Button1Click(Sender:TObject);
    procedure Button2Click(Sender:TObject);
    function AktivierenviaInternet():boolean;
    function AktivierenviaFile():boolean;
    function AktivierenviaCode(Name,Code:JString):boolean;
    function AktivierenGetWinProdId(Ed:Editions):JString;
    procedure Button3Click(Sender:TObject);
    procedure TrytoActivate(goon:boolean);
    procedure checklicense();inline;
    procedure checklicensesum();inline;
    procedure checknetwork();inline;
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
    goon:boolean;
  end;
  //------------------------------------------------------------------------------
  //
  //------------------------------------------------------------------------------
var
  Lizenz1:TLizenzForm;
  //------------------------------------------------------------------------------
  //
  //------------------------------------------------------------------------------
implementation
uses
  Messages,SysUtils,Variants,Graphics,
  Strutils,Dialogs,ClipBrd;
{$R *.dfm}
//------------------------------------------------------------------------------
//
//check license sum
//
//------------------------------------------------------------------------------
procedure TLizenzForm.checklicensesum();
var
  ll1,ll2,ll3,ll4,ll5,ll6,ll7,ll8,rand:integer;
begin
  ll1:=Opt.OptSum();
  ll2:=Opt.OptLen();
  if (Opt.R.OptionSum<>ll1)or(Opt.R.OptionLen<>ll2) then begin
    Opt.R.Activated:=false;
    errorn(112,'Lizenz abgelaufen');
    ExitProcess(99);
  end;
  RandSeed:=GetCurrentTime;
  rand:=random(GetCurrentTime);
  if (rand mod 7<0) then begin
    ll1:=Opt.R.CobolDllLen;
    ll2:=Opt.R.CobolDllSum;
    ll3:=Opt.R.ColumboLen;
    ll4:=Opt.R.ColumboSum;
    ll5:=getFileLength(Extensions[1].dllname+dlle);
    ll6:=getFileSum(Extensions[1].dllname+dlle);
    ll7:=getFileLength(ColumboFileName);
    ll8:=getFileSum(ColumboFileName);
    if (ll1<>ll5)or
      (ll2<>ll6)or
      (ll3<>ll7)or
      (ll4<>ll8) then begin
      Opt.R.Activated:=false;
      Opt.R.Activationstart:=false;
      Opt.R.OptionSum:=0;
    end
  end
end;
//------------------------------------------------------------------------------
//
//check for network fake
//
//------------------------------------------------------------------------------
procedure TLizenzForm.checknetwork();
var
  ip:JString;
begin
  ip:=getIP('cococo.de');
  if ip<>'0' then
    if ip<>'87.230.16.129' then
      Opt.R.Activated:=false;
end;
//------------------------------------------------------------------------------
//
//check license
//
//------------------------------------------------------------------------------
procedure TLizenzForm.checklicense();
var
  ll1,ll2,ll3,ll4:integer;
  WI:JString;
  TD:Tdate;
begin
  //
  if (Opt.R.Activationstart<>Opt.R.Activated) then begin
    SplashForm1.setInfo(trans(lang,149,'es wird gesäubert'));
    SplashForm1.init(15);
    Cursor:=crHourGlass;
    ll3:=Opt.R.ColumboLen;
    ll4:=Opt.R.ColumboSum;
    if (ll3<>getFileLength(ColumboFileName))or
      (ll4<>getFileSum(ColumboFileName)) then begin
      SplashForm1.Progress(9);
      Opt.R.Activated:=false;
      Opt.R.Activationstart:=false;
      Opt.R.OptionSum:=0;
      TrytoActivate(false);
    end
    else
      Opt.R.Activationstart:=Opt.R.Activated;
  end;
  WI:=GetWinProductId;
  TD:=today;
  if (WI<>Opt.R.WindowsProductId)or(Opt.R.LastUse>TD) then begin
    Opt.R.Activated:=false;
    Opt.R.Edition:=Standard;
    TrytoActivate(false);
  end;
  //check after n days (like Windows does)
  if (Now>Opt.R.NextCheck) then begin
    ll1:=getFileLength(ColumboFileName);
    ll2:=getFileSum(ColumboFileName);
    ll3:=Opt.R.ColumboLen;
    ll4:=Opt.R.ColumboSum;
    if (ll3<>ll1)or(ll4<>ll2)
      or(GetWinProductId<>Opt.R.WindowsProductId) then
      TrytoActivate(false)
    else
      Opt.R.NextCheck:=incday(Now,LicenseCheckInterval);
  end;
end;
//------------------------------------------------------------------------------
//
//activate via Internet
//
//------------------------------------------------------------------------------
function TLizenzForm.AktivierenviaInternet():boolean;
var
  Prod:JString;
  Edit:JString;
  E:Editions;
  found:boolean;
begin
  found:=false;
  //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.PutOptions(PChar(Optionsfilename(Application.Title)));
        Close();
        inform(54,'Bitte neu starten','');
        SetSecrets(Installkey,0,Productnumber);
        found:=true;
      end;
    //SQLUpdate(Code,GetWinProductId,'IP',getCPUID,getDiskId(GetCurrentdir()),'');
  end;
  AktivierenviaInternet:=found;
end;
//------------------------------------------------------------------------------
//
//activate via Internet
//
//------------------------------------------------------------------------------
function TLizenzForm.AktivierenGetWinProdId(Ed:Editions):JString;
var
  Inp,Erg,Key: array [0..64] of Char;
  Pin,Pout,Pkey:PChar;
  C3,Edit,mke:JString;
  i:integer;
begin
  //make key
  mke:='';
  for i:=1 to 8 do
    mke:=mke+chr(ord(i-1)+ord('a'));
  strpcopy(Key,mke);//secret key  'abcdefgh'
  Pin:=@Inp;
  Pout:=@Erg;
  Pkey:=@Key;
  //code to get winprodid
  Edit:=EditionStrings[Ed];
  C3:=GetWinProductId()+'-'+Edit;
  if Length(C3)>Codelength then
    errorn(116,'Code zu lang!');
  while Length(C3)<Codelength do
    C3:=C3+' ';
  strpcopy(Pout,'');
  strpcopy(Pin,PChar(C3));
  Opt.DoActivate(Pin,Pout,Pkey);
  strpcopy(Pin,'');
  AktivierenGetWinProdId:=Pout;
end;
//------------------------------------------------------------------------------
//
//activate via Internet
//
//------------------------------------------------------------------------------
function TLizenzForm.AktivierenviaCode(Name,Code:JString):boolean;
var
  Inp,Erg,Win,Key: array [0..128] of Char;
  E:Editions;
  found:boolean;
  Pin,Pout,Pwin,Pkey:PChar;
  C1,C2,Edit,Applic,mke,CodeName:JString;
  i,j:integer;
begin
  found:=false;
  //make key
  mke:='';
  for i:=1 to 8 do
    mke:=mke+chr(ord(i-1)+ord('a'));
  strpcopy(Key,mke);//secret key  'abcdefgh'
  Pin:=@Inp;
  Pout:=@Erg;
  Pkey:=@Key;
  Pwin:=@Win;
  //-------------------------------------------------
  //encode here   -  simple licensing
  //-------------------------------------------------
  //
  //Applic:='55375-OEM-0044992-91858-Elbe-Standard';
  //for i:=length(Applic)+1 to 64 do Applic:=Applic+' ';
  //strpcopy(Pin,Applic);
  //strpcopy(Pout,'');
  //Opt.DoActivate(Pin,Pout,Pkey);
  //
  //-------------------------------------------------
  //get product ID
  //-------------------------------------------------
  strpcopy(Pwin,GetWinProductId());
  //now decode Code
  strpcopy(Pin,'');
  strpcopy(Pout,PChar(Code));
  Opt.DoActivate(Pin,Pout,Pkey);
  //compare WinproductId
  C1:=Pwin;
  C2:=Trim(Pin);
  //extract Editiomn
  i:=Length(C2);
  while (i>0)and CharinSet(C2[i],['a'..'z','A'..'Z','0'..'9',' ']) do
    i:=i-1;
  CodeName:=MidStr(C2,i+1,Length(C2)-i);
  //extract Edition
  i:=i-2;
  j:=i;
  while (i>0)and CharinSet(C2[i],['a'..'z','A'..'Z','0'..'9']) do
    i:=i-1;
  Edit:=MidStr(C2,i+1,j-i+1);
  //extract Name
  i:=i-2;
  j:=i;
  while (i>0)and CharinSet(C2[i],['a'..'z','A'..'Z','0'..'9']) do
    i:=i-1;
  Applic:=MidStr(C2,i+1,j-i+1);
  //now compare
  //now compare
  Name:=Trim(Name);
  CodeName:=Trim(CodeName);
  if LowerCase(Name)=LowerCase(CodeName) then begin
    if LowerCase(Applic)=LowerCase(Application.Title) then begin
      C2:=MidStr(C2,1,i-1);
      //get ProductId
      if LowerCase(C1)=LowerCase(C2) then begin
        for E:= low(Editions) to High(Editions) do
          if EditionStrings[E]=Edit then begin
            SplashForm1.setInfo(trans(lang,138,'Software wird aktiviert...'));
            SplashForm1.init(15);
            setl(Opt.R.UserName,Name);
            Opt.R.Edition:=E;
            Opt.R.Activated:=true;
            Opt.R.ColumboLen:=getFileLength(ColumboFileName);
            SplashForm1.Progress(3);
            Opt.R.ColumboSum:=getFileSum(ColumboFileName);
            SplashForm1.Progress(7);
            Opt.PutOptions(PChar(Optionsfilename(Application.Title)));
            Close();
            inform(55,'Bitte neu starten','');
            SetSecrets(Installkey,0,Productnumber);
            ExitProcess(0);
          end;
      end;
    end;
  end
  else
    inform(55,'falscher Name','');
  AktivierenviaCode:=found;
end;
//------------------------------------------------------------------------------
//
//activate via Internet
//
//------------------------------------------------------------------------------
function TLizenzForm.AktivierenviaFile():boolean;
var
  License:TextFile;
  found:boolean;
  Licname:JString;
  Name,Code:JString;
begin
  Licname:=Opt.R.ProgramDir+Application.Title+'.lic';
  Code:='';
  AssignFile(License,Licname);
  if fileexists(Licname) then begin
    Reset(License);
    Readln(License,Name);
    Readln(License,Code);
    CloseFile(License);
    found:=AktivierenviaCode(Name,Code);
  end
  else begin
    Code:='';
    found:=false;
  end;
  AktivierenviaFile:=found;
end;
//------------------------------------------------------------------------------
//
//check edition
//
//------------------------------------------------------------------------------
procedure TLizenzForm.TrytoActivate(goon:boolean);
begin
  dostop:=not goon;
  if not AktivierenviaFile() then
    if not goon then begin
      ShowModal();
      if modalresult<>mrCancel then
        ExitProcess(0);
    end;
end;
//------------------------------------------------------------------------------
//
//check edition
//
//------------------------------------------------------------------------------
procedure TLizenzForm.Button1Click(Sender:TObject);
var
  Name,Code:JString;
begin
  Name:=Edit1.Text;
  Code:=Edit2.Text;
  //code to get winprodid
  //AktivierenGetWinProdId();
  if Length(Code)<=MySQLlength then
    AktivierenviaInternet()
  else
    AktivierenviaCode(Name,Code);
end;
//------------------------------------------------------------------------------
//
//check edition
//
//------------------------------------------------------------------------------
procedure TLizenzForm.Button2Click(Sender:TObject);
begin
  //if dostop then
  //ExitProcess(0);
end;
//------------------------------------------------------------------------------
//
//check edition
//
//------------------------------------------------------------------------------
procedure TLizenzForm.Button3Click(Sender:TObject);
begin
  if netallowed then
    Browser(Handle,
      'https://cococo.de/Context_IT_GmbH/index.jsp?content=license&detail='+
        Application.Title);
end;
//------------------------------------------------------------------}
//-}
//Ende dieser Quelle                                           -}
//-}
//-----------------------------------------------------------------}
end.

¤ Dauer der Verarbeitung: 0.17 Sekunden  (vorverarbeitet)  ¤





Download des
Quellennavigators
Download des
sprechenden Kalenders

in der Quellcodebibliothek suchen




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.


Bot Zugriff