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 / SAMPLE4.PAS < prev   
Pascal/Delphi Source File  |  1993-03-04  |  5KB  |  201 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 Rkp2Enc unit to cause RkPlus to maintain version
  17.  2.x/compatible keys.
  18. }
  19.  
  20.  
  21. Uses
  22.   Crt,
  23.   RkPlus,
  24.   Rkp2Enc;
  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.  
  35.  
  36. Procedure BadRegBeep;
  37.  
  38. Begin
  39.   Sound(1200);
  40.   Delay(200);
  41.   Sound(600);
  42.   Delay(200);
  43.   Sound(1200);
  44.   Delay(200);
  45.   Sound(600);
  46.   Delay(200);
  47.   NoSound;
  48. End;
  49.  
  50.  
  51. Procedure NotRegBeep;
  52.  
  53. Begin
  54.   Sound(600);
  55.   Delay(200);
  56.   Sound(1200);
  57.   Delay(200);
  58.   NoSound;
  59. End;
  60.  
  61.  
  62. Procedure DoView;
  63.  
  64. Begin
  65.   WriteLn('Sample data :');
  66.   WriteLn;
  67.   WriteLn('4.465536  7.918270  0.118373  5.367233');
  68.   WriteLn('1.396349  4.868343  7.079323  4.783021');
  69.   WriteLn('3.947924  8.864673  8.846264  2.999999');
  70.   WriteLn('8.490832  6.874378  5.338329  3.729270');
  71.   WriteLn('6.839882  8.873478  6.750373  7.018948');
  72.   WriteLn('5.034784  3.003763  3.253290  4.892387');
  73.   WriteLn('3.874378  8.314159  9.880869  3.987842');
  74.   WriteLn('2.764947  9.265358  4.013002  9.903278');
  75. End;
  76.  
  77.  
  78. Procedure DoCalc;
  79.  
  80. Begin
  81.   If Rkp.Registered then Begin
  82.     Write('The calculated result is ');
  83.     WriteLn(4.465536+7.918270+0.118373+5.367233+1.396349+4.868343+7.079323+4.783021
  84.     +3.947924+8.864673+8.846264+2.999999+8.490832+6.874378+5.338329+3.729270
  85.     +6.839882+8.873478+6.750373+7.018948+5.034784+3.003763+3.253290+4.892387
  86.     +3.874378+8.314159+9.880869+3.987842+2.764947+9.265358+4.013002+9.903278);
  87.   End Else
  88.     WriteLn('Only available in registered version!');
  89. End;
  90.  
  91.  
  92. Procedure DoTest;
  93.  
  94. Begin
  95.   If Rkp.Registered then Begin
  96.     If (Rkp.Level > 0) then Begin
  97.       Write('Performing tests...');
  98.       Delay(300);
  99.       WriteLn;
  100.       WriteLn('All tests passed.');
  101.     End Else
  102.       WriteLn('Not available in demo version!');
  103.   End Else
  104.     WriteLn('Only available in registered version!');
  105. End;
  106.  
  107.  
  108. Begin
  109.   If Not RkpOK then Begin
  110.     WriteLn('Unexpected Error ',RkpError,'!');
  111.     Halt(255);
  112.   End;
  113.   If BadSystemDate then Begin
  114.     WriteLn('You must correctly set your system clock to run Demo!');
  115.     BadRegBeep;
  116.     Halt(1);
  117.   End;
  118.   OwnerCode := 'ArgleBarbWotsLeeb';
  119.   ProgramCode := 'Sample';
  120.   VerifyKey;
  121.   Write('Sample4');
  122.   If Not RkpOK then
  123.     WriteLn(' [invalid]')
  124.   Else If Rkp.Registered and (Rkp.Level > 0) then
  125.     WriteLn(' [registered]')
  126.   Else If Rkp.Registered then
  127.     WriteLn(' [demo]')
  128.   Else
  129.     WriteLn(' [unregistered]');
  130.   WriteLn('Sample of RkPlus method 5 (using version 2.x/compatible keys)');
  131.   WriteLn('See RKPLUS.DOC for more info');
  132.   WriteLn;
  133.   If (RkpError = InvalidFile) or (RkpError = InvalidKey) then Begin
  134.     WriteLn(ExeFileName,' has been altered!');
  135.     BadRegBeep;
  136.     Halt(1);
  137.   End Else If (RkpError = ExpiredKey) then Begin
  138.     If (Rkp.Level > 0) then Begin
  139.       WriteLn('Your registration key has expired!');
  140.       WriteLn('You will be given access at the DEMO level.');
  141.       NotRegBeep;
  142.       Rkp.Level := 0;
  143.     End Else Begin
  144.       WriteLn('Your limited use demo key has expired!');
  145.       WriteLn('You will be given access at the UNREGISTERED level.');
  146.       NotRegBeep;
  147.       Rkp.Registered := False;
  148.     End;
  149.   End Else If Rkp.Registered then Begin
  150.     If (Rkp.Level > 0) then Begin
  151.       WriteLn('This version of Sample4 is registered to ',Rkp.Name1);
  152.       If (Rkp.ExpYear <> 0) and (Rkp.ExpMonth <> 0) then
  153.         WriteLn('This registration will expire ','1-',MonthNames[Rkp.ExpMonth],'-',Rkp.ExpYear,'.');
  154.       WriteLn('Thank you for registering!');
  155.     End Else Begin
  156.       WriteLn('This version of Sample4 is a limited use demo for ',Rkp.Name1);
  157.       If (Rkp.ExpYear <> 0) and (Rkp.ExpMonth <> 0) then
  158.         WriteLn('This limited use demo will expire ','1-',MonthNames[Rkp.ExpMonth],'-',Rkp.ExpYear,'.');
  159.       WriteLn('Don''t forget to register!');
  160.     End;
  161.   End Else If Not RkpOK then Begin
  162.     WriteLn('Unexpected error ',RkpError,'!');
  163.     Halt(255);
  164.   End Else Begin
  165.     WriteLn('This version of Sample4 is unregistered.');
  166.     NotRegBeep;
  167.     Delay(500);
  168.   End;
  169.   WriteLn;
  170.   WriteLn('Sample4 Menu');
  171.   WriteLn;
  172.   WriteLn('[V]iew sample data');
  173.   Write('[C]alculate');
  174.   If Not Rkp.Registered then
  175.     WriteLn('  (only available in registered version)')
  176.   Else
  177.     WriteLn;
  178.   Write('[T]est results');
  179.   If Not Rkp.Registered then
  180.     WriteLn('  (only available in registered version)')
  181.   Else If (Rkp.Level <= 0) then
  182.     WriteLn('  (not available in demo version)')
  183.   Else
  184.     WriteLn;
  185.   WriteLn;
  186.   Write('Selection : ');
  187.   kc := UpCase(ReadKey);
  188.   WriteLn;
  189.   WriteLn;
  190.   Case kc of
  191.   'V' :
  192.     DoView;
  193.   'C' :
  194.     DoCalc;
  195.   'T' :
  196.     DoTest;
  197.   Else
  198.     WriteLn('Invalid selection!');
  199.   End;
  200. End.
  201.