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

  1. Program Sample4;
  2.  
  3. {
  4.  This is a sample programme using RkPlus.
  5.  It uses 2 registration levels (0 and 1).
  6.  If a Level 1 key has expired, it will be treated as Level 0.
  7.  If a Level 0 key has expired, it will be treated as Unregistered.
  8.  This is a very simple programme that doesn't actually do anything, but it
  9.  should demonstrate some of what can be done with RkPlus.
  10.  
  11.  It is identical to Sample1, except that it uses a "branding" programme
  12.  (such as Brand) to write the information directly into the EXE file,
  13.  rather than using a key file.  It uses the same keys as Sample1 (which
  14.  can be generated with GenKey).
  15.  
  16.  Sample4 uses the Rkp3Enc unit to cause RkPlus to use the new version 3.x
  17.  keys.
  18. }
  19.  
  20.  
  21. Uses
  22.   Crt,
  23.   RkPlus,
  24.   Rkp3Enc;
  25.  
  26.  
  27. Const
  28.   MonthNames : Array[1..12] of String[3]
  29.   = ('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
  30.  
  31.  
  32. Var
  33.   kc : Char;
  34.   Owner : Array[0..16] of Char;
  35.   Prog  : Array[0..5] of Char;
  36.   Ver   : Real;
  37.  
  38.  
  39. Procedure BadRegBeep;
  40.  
  41. Begin
  42.   Sound(1200);
  43.   Delay(200);
  44.   Sound(600);
  45.   Delay(200);
  46.   Sound(1200);
  47.   Delay(200);
  48.   Sound(600);
  49.   Delay(200);
  50.   NoSound;
  51. End;
  52.  
  53.  
  54. Procedure NotRegBeep;
  55.  
  56. Begin
  57.   Sound(600);
  58.   Delay(200);
  59.   Sound(1200);
  60.   Delay(200);
  61.   NoSound;
  62. End;
  63.  
  64.  
  65. Procedure DoView;
  66.  
  67. Begin
  68.   WriteLn('Sample data :');
  69.   WriteLn;
  70.   WriteLn('4.465536  7.918270  0.118373  5.367233');
  71.   WriteLn('1.396349  4.868343  7.079323  4.783021');
  72.   WriteLn('3.947924  8.864673  8.846264  2.999999');
  73.   WriteLn('8.490832  6.874378  5.338329  3.729270');
  74.   WriteLn('6.839882  8.873478  6.750373  7.018948');
  75.   WriteLn('5.034784  3.003763  3.253290  4.892387');
  76.   WriteLn('3.874378  8.314159  9.880869  3.987842');
  77.   WriteLn('2.764947  9.265358  4.013002  9.903278');
  78. End;
  79.  
  80.  
  81. Procedure DoCalc;
  82.  
  83. Begin
  84.   If Rkp.Registered then Begin
  85.     Write('The calculated result is ');
  86.     WriteLn(4.465536+7.918270+0.118373+5.367233+1.396349+4.868343+7.079323+4.783021
  87.     +3.947924+8.864673+8.846264+2.999999+8.490832+6.874378+5.338329+3.729270
  88.     +6.839882+8.873478+6.750373+7.018948+5.034784+3.003763+3.253290+4.892387
  89.     +3.874378+8.314159+9.880869+3.987842+2.764947+9.265358+4.013002+9.903278);
  90.   End Else
  91.     WriteLn('Only available in registered version!');
  92. End;
  93.  
  94.  
  95. Procedure DoTest;
  96.  
  97. Begin
  98.   If Rkp.Registered then Begin
  99.     If (Rkp.Level > 0) then Begin
  100.       Write('Performing tests...');
  101.       Delay(300);
  102.       WriteLn;
  103.       WriteLn('All tests passed.');
  104.     End Else
  105.       WriteLn('Not available in demo version!');
  106.   End Else
  107.     WriteLn('Only available in registered version!');
  108. End;
  109.  
  110.  
  111. Begin
  112.   If Not RkpOK then Begin
  113.     WriteLn('Unexpected Error ',RkpError,'!');
  114.     Halt(255);
  115.   End;
  116.   If BadSystemDate then Begin
  117.     WriteLn('You must correctly set your system clock to run Demo!');
  118.     BadRegBeep;
  119.     Halt(1);
  120.   End;
  121.   Owner := 'ArgleBarbWotsLeeb';
  122.   Prog := 'Sample';
  123.   Ver := 1.0;
  124.   SetOwnerCode(Owner,SizeOf(Owner));
  125.   SetProgCode(Prog,SizeOf(Prog));
  126.   SetVerCode(Ver,SizeOf(Ver));
  127.   VerifyKey;
  128.   Write('Sample4');
  129.   If Not RkpOK then
  130.     WriteLn(' [invalid]')
  131.   Else If Rkp.Registered and (Rkp.Level > 0) then
  132.     WriteLn(' [registered]')
  133.   Else If Rkp.Registered then
  134.     WriteLn(' [demo]')
  135.   Else
  136.     WriteLn(' [unregistered]');
  137.   WriteLn('Sample of RkPlus method 5 (using version 3.x/compatible keys)');
  138.   WriteLn('See RKPLUS.DOC for more info');
  139.   WriteLn;
  140.   If (RkpError = InvalidFile) or (RkpError = InvalidKey) then Begin
  141.     WriteLn(ExeFileName,' has been altered!');
  142.     BadRegBeep;
  143.     Halt(1);
  144.   End Else If (RkpError = ExpiredKey) then Begin
  145.     If (Rkp.Level > 0) then Begin
  146.       WriteLn('Your registration key has expired!');
  147.       WriteLn('You will be given access at the DEMO level.');
  148.       NotRegBeep;
  149.       Rkp.Level := 0;
  150.     End Else Begin
  151.       WriteLn('Your limited use demo key has expired!');
  152.       WriteLn('You will be given access at the UNREGISTERED level.');
  153.       NotRegBeep;
  154.       Rkp.Registered := False;
  155.     End;
  156.   End Else If Rkp.Registered then Begin
  157.     If (Rkp.Level > 0) then Begin
  158.       WriteLn('This version of Sample4 is registered to ',Rkp.Name1);
  159.       If (Rkp.ExpYear <> 0) and (Rkp.ExpMonth <> 0) then
  160.         WriteLn('This registration will expire ','1-',MonthNames[Rkp.ExpMonth],'-',Rkp.ExpYear,'.');
  161.       WriteLn('Thank you for registering!');
  162.     End Else Begin
  163.       WriteLn('This version of Sample4 is a limited use demo for ',Rkp.Name1);
  164.       If (Rkp.ExpYear <> 0) and (Rkp.ExpMonth <> 0) then
  165.         WriteLn('This limited use demo will expire ','1-',MonthNames[Rkp.ExpMonth],'-',Rkp.ExpYear,'.');
  166.       WriteLn('Don''t forget to register!');
  167.     End;
  168.   End Else If Not RkpOK then Begin
  169.     WriteLn('Unexpected error ',RkpError,'!');
  170.     Halt(255);
  171.   End Else Begin
  172.     WriteLn('This version of Sample4 is unregistered.');
  173.     NotRegBeep;
  174.     Delay(500);
  175.   End;
  176.   WriteLn;
  177.   WriteLn('Sample4 Menu');
  178.   WriteLn;
  179.   WriteLn('[V]iew sample data');
  180.   Write('[C]alculate');
  181.   If Not Rkp.Registered then
  182.     WriteLn('  (only available in registered version)')
  183.   Else
  184.     WriteLn;
  185.   Write('[T]est results');
  186.   If Not Rkp.Registered then
  187.     WriteLn('  (only available in registered version)')
  188.   Else If (Rkp.Level <= 0) then
  189.     WriteLn('  (not available in demo version)')
  190.   Else
  191.     WriteLn;
  192.   WriteLn;
  193.   Write('Selection : ');
  194.   kc := UpCase(ReadKey);
  195.   WriteLn;
  196.   WriteLn;
  197.   Case kc of
  198.   'V' :
  199.     DoView;
  200.   'C' :
  201.     DoCalc;
  202.   'T' :
  203.     DoTest;
  204.   Else
  205.     WriteLn('Invalid selection!');
  206.   End;
  207. End.
  208.