home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 2 / ctrom_ii_b.zip / ctrom_ii_b / PROGRAM / PASCAL / RKPLUS33 / RKPDEMO3 / GENKEY.PAS < prev    next >
Pascal/Delphi Source File  |  1993-10-19  |  3KB  |  121 lines

  1. Program GenKey;
  2.  
  3. {
  4.  This is a sample programme using RkPlus.  It is a sample of a registration
  5.  key generation programme that would be used by the programmer to create
  6.  registration keys to be distributed to registered users.  The user would
  7.  then enter the registration key into a registration programme (such as
  8.  Register or Brand) to create the key file. The key generation programme
  9.  itself would NOT be distributed, as it would allow users to generate keys.
  10.  This sample can create a 1 or 2 month limited use demo key, a 1 year
  11.  registration key or an unlimited registration key, for the Sample1, Sample2,
  12.  Sample3 and Sample4 programmes.
  13.  
  14.  GenKey uses the Rkp3Enc unit to cause RkPlus to use the new version 3.x
  15.  keys.
  16. }
  17.  
  18.  
  19. Uses
  20.   Crt,
  21.   Dos,
  22.   RkPlus,
  23.   Rkp3Enc;
  24.  
  25.  
  26. Const
  27.   MonthNames : Array[1..12] of String[3]
  28.   = ('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
  29.  
  30.  
  31. Var
  32.   kc          : Char;
  33.   ey,em,dd,dw : Word;
  34.   Owner : Array[0..16] of Char;
  35.   Prog  : Array[0..5] of Char;
  36.   Ver   : Real;
  37.  
  38.  
  39. Begin
  40.   Owner := 'ArgleBarbWotsLeeb';
  41.   Prog := 'Sample';
  42.   Ver := 1.0;
  43.   SetOwnerCode(Owner,SizeOf(Owner));
  44.   SetProgCode(Prog,SizeOf(Prog));
  45.   SetVerCode(Ver,SizeOf(Ver));
  46.   SetKeyFile('Sample');
  47.   WriteLn('GenKey');
  48.   WriteLn('Registration Key Generation Programme for Sample1/Sample2/Sample3/Sample4');
  49.   WriteLn('See RKPLUS.DOC for more info');
  50.   WriteLn;
  51.   WriteLn('GenKey would be used by the programmer to create registration keys.');
  52.   WriteLn('It would NOT be distributed.');
  53.   WriteLn;
  54.   Write('Enter name of person to register : ');
  55.   ReadLn(Rkp.Name1);
  56.   WriteLn;
  57.   WriteLn('[1] 1 month limited use demo key');
  58.   WriteLn('[2] 2 month limited use demo key');
  59.   WriteLn('[R] registration key (1 year)');
  60.   WriteLn('[U] unlimited registration key');
  61.   WriteLn;
  62.   Write('Type? ');
  63.   kc := UpCase(ReadKey);
  64.   WriteLn(kc);
  65.   WriteLn;
  66.   GetDate(ey,em,dd,dw);
  67.   If (kc = '1') then Begin
  68.     If (em = 12) then Begin
  69.       em := 1;
  70.       Inc(ey);
  71.     End Else
  72.       Inc(em);
  73.     WriteLn('Creating limited use demo key (will expire 1-',MonthNames[em],'-',ey,')');
  74.     Rkp.Level := 0;
  75.     Rkp.ExpYear := ey;
  76.     Rkp.ExpMonth := em;
  77.     Rkp.ExpDay := 1;
  78.   End Else If (kc = '2') then Begin
  79.     If (em = 11) then Begin
  80.       em := 1;
  81.       Inc(ey);
  82.     End Else If (em = 12) then Begin
  83.       em := 2;
  84.       Inc(ey);
  85.     End Else Begin
  86.       Inc(em,2);
  87.     End;
  88.     WriteLn('Creating limited use demo key (will expire 1-',MonthNames[em],'-',ey,')');
  89.     Rkp.Level := 0;
  90.     Rkp.ExpYear := ey;
  91.     Rkp.ExpMonth := em;
  92.     Rkp.ExpDay := 1;
  93.   End Else If (kc in ['R','r']) then Begin
  94.     If (em = 12) then Begin
  95.       em := 1;
  96.       Inc(ey);
  97.     End Else
  98.       Inc(em);
  99.     Inc(ey);
  100.     WriteLn('Creating registration key (will expire 1-',MonthNames[em],'-',ey,')');
  101.     Rkp.Level := 1;
  102.     Rkp.ExpYear := ey;
  103.     Rkp.ExpMonth := em;
  104.     Rkp.ExpDay := 1;
  105.   End Else Begin
  106.     WriteLn('Creating unlimited registration key');
  107.     Rkp.Level := 1;
  108.     Rkp.ExpYear := 0;
  109.     Rkp.ExpMonth := 0;
  110.     Rkp.ExpDay := 0;
  111.   End;
  112.   Rkp.Name2 := '';
  113.   Rkp.Name3 := '';
  114.   CreateKey;
  115.   WriteLn;
  116.   If Not RkpOK then
  117.     WriteLn('Unexpected error ',RkpError)
  118.   Else
  119.     WriteLn('Key is ',Rkp.Key);
  120. End.
  121.