home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-387-Vol-3of3.iso / r / rkpls301.zip / RKPDEMO2.ZIP / GENKEY.PAS < prev    next >
Pascal/Delphi Source File  |  1993-03-04  |  3KB  |  107 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 Rkp2Enc unit to cause RkPlus to maintain version
  15.  2.x/compatible keys.
  16. }
  17.  
  18.  
  19. Uses
  20.   Crt,
  21.   Dos,
  22.   RkPlus,
  23.   Rkp2Enc;
  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.  
  35.  
  36. Begin
  37.   OwnerCode := 'ArgleBarbWotsLeeb';
  38.   ProgramCode := 'Sample';
  39.   SetKeyFile('Sample');
  40.   WriteLn('GenKey');
  41.   WriteLn('Registration Key Generation Programme for Sample1/Sample2/Sample3/Sample4');
  42.   WriteLn('See RKPLUS.DOC for more info');
  43.   WriteLn;
  44.   WriteLn('GenKey would be used by the programmer to create registration keys.');
  45.   WriteLn('It would NOT be distributed.');
  46.   WriteLn;
  47.   Write('Enter name of person to register : ');
  48.   ReadLn(Rkp.Name1);
  49.   WriteLn;
  50.   WriteLn('[1] 1 month limited use demo key');
  51.   WriteLn('[2] 2 month limited use demo key');
  52.   WriteLn('[R] registration key (1 year)');
  53.   WriteLn('[U] unlimited registration key');
  54.   WriteLn;
  55.   Write('Type? ');
  56.   kc := UpCase(ReadKey);
  57.   WriteLn(kc);
  58.   WriteLn;
  59.   GetDate(ey,em,dd,dw);
  60.   If (kc = '1') then Begin
  61.     If (em = 12) then Begin
  62.       em := 1;
  63.       Inc(ey);
  64.     End Else
  65.       Inc(em);
  66.     WriteLn('Creating limited use demo key (will expire 1-',MonthNames[em],'-',ey,')');
  67.     Rkp.Level := 0;
  68.     Rkp.ExpYear := ey;
  69.     Rkp.ExpMonth := em;
  70.   End Else If (kc = '2') then Begin
  71.     If (em = 11) then Begin
  72.       em := 1;
  73.       Inc(ey);
  74.     End Else If (em = 12) then Begin
  75.       em := 2;
  76.       Inc(ey);
  77.     End Else Begin
  78.       Inc(em,2);
  79.     End;
  80.     WriteLn('Creating limited use demo key (will expire 1-',MonthNames[em],'-',ey,')');
  81.     Rkp.Level := 0;
  82.     Rkp.ExpYear := ey;
  83.     Rkp.ExpMonth := em;
  84.   End Else If (kc in ['R','r']) then Begin
  85.     If (em = 12) then Begin
  86.       em := 1;
  87.       Inc(ey);
  88.     End Else
  89.       Inc(em);
  90.     Inc(ey);
  91.     WriteLn('Creating registration key (will expire 1-',MonthNames[em],'-',ey,')');
  92.     Rkp.Level := 1;
  93.     Rkp.ExpYear := ey;
  94.     Rkp.ExpMonth := em;
  95.   End Else Begin
  96.     WriteLn('Creating unlimited registration key');
  97.     Rkp.Level := 1;
  98.     Rkp.ExpYear := 0;
  99.     Rkp.ExpMonth := 0;
  100.   End;
  101.   Rkp.Name2 := '';
  102.   Rkp.Name3 := '';
  103.   CreateKey;
  104.   WriteLn;
  105.   WriteLn('Key is ',Rkp.Key);
  106. End.
  107.