home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / FLXKEY10.ZIP / MAKEKEY1.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1992-10-01  |  4.6 KB  |  114 lines

  1.  
  2. (**********************************************************************)
  3. (* Simple program to demonstrate how to use the FlxKey unit to create *)
  4. (* an encrypted registration-key file.                                *)
  5. (**********************************************************************)
  6.  
  7. program MakeFlxKeyDemo1;
  8. uses
  9.   FlxKey;
  10.  
  11. var           (* This variable is used to check for errors returned   *)
  12.               (* by CreateFlxKey routine.                             *)
  13.   ErrorCode : word;
  14.  
  15.               (* Encryption-code strings used to create encrypted     *)
  16.               (* registration-key file.                               *)
  17.   Ecode1,
  18.   Ecode2 : st100;
  19.  
  20.               (* This is the full path/filename of the encrypted      *)
  21.               (* registration-key file to be created.                 *)
  22.   RegKeyName : st79;
  23.  
  24.               (* This variable is used to pass the user-data to the   *)
  25.               (* CreateFlxKey routine.                                *)
  26.   TempKeyRec : FlxRec;
  27.  
  28.               (* Main program execution block.                        *)
  29. BEGIN
  30.               (* Clear the temporary key-record variable.             *)
  31.   fillchar(TempKeyRec, sizeof(TempKeyRec), 0);
  32.  
  33.               (* Assign data to temporary key-record.                 *)
  34.   with TempKeyRec do
  35.     begin
  36.               (* 20 char space is available for first-name.           *)
  37.       FirstName := 'John';
  38.  
  39.               (* 30 char space is available for last-name.            *)
  40.       LastName  := 'Smith';
  41.  
  42.               (* 30 char space is available for Address1.             *)
  43.       Address1  := '1234 AnyPlace Road,';
  44.  
  45.               (* 30 char space is available for Address2.             *)
  46.       Address2  := 'BigCity BigPlace,';
  47.  
  48.               (* 30 char space is available for Address3.             *)
  49.       Address3  := 'BigCountry, BigZip';
  50.  
  51.               (* 20 char space is available for application-name.     *)
  52.       AppName   := 'Amazing Program';
  53.  
  54.               (* Version can be assigned any valid word data.         *)
  55.       Version   := 310;
  56.  
  57.               (* Serial can be assigned any valid longint data.       *)
  58.       Serial    := 1234567890;
  59.  
  60.               (* Date can be assigned any valid "packed" date/time.   *)
  61.               (* If a value of 0 is assigned to Date, CreateFlxKey    *)
  62.               (* routine will assign the current date/time to this    *)
  63.               (* variable in "packed" date/time format. Use TP's      *)
  64.               (* standard "PackTime" and "UnPackTime" routines to     *)
  65.               (* manipulate this data.                                *)
  66.       Date      := 0;
  67.  
  68.               (* Access level can be assigned a number from 0..65,535 *)
  69.       Access    := 1234
  70.     end;
  71.  
  72.               (* Assign encryption-code strings used to create the    *)
  73.               (* encrypted registration-key file.                     *)
  74.   Ecode1 := 'Apple';
  75.   Ecode2 := 'Orange';
  76.  
  77.               (* Filename for the encrypted registration-key to be    *)
  78.               (* created.                                             *)
  79.   RegKeyName := 'DEMO1.KEY';
  80.  
  81.               (* Create encrypted registration-key using the data     *)
  82.               (* assigned to TempKeyRec.                              *)
  83.   CreateFlxKey(TempKeyRec, Ecode1, Ecode2, RegKeyName, ErrorCode);
  84.  
  85.               (* Move cursor down one line.                           *)
  86.   writeln;
  87.  
  88.               (* Check for errors.                                    *)
  89.   case (ErrorCode AND $FF) of
  90.      0 : writeln(' Sucessful key creation! No errors.');
  91.      1 : writeln(' Error! One or more encryption-codes are blank.');
  92.      2 : writeln(' Error! Filename for registration-key file is blank.');
  93.  
  94.               (* I/O error!                                           *)
  95.     16 : begin
  96.            writeln(' I/O error = ', (ErrorCode shr 8));
  97.  
  98.               (* Standard Turbo Pascal error-codes. See TP manuals,   *)
  99.               (* as there are many types of errors to check for.      *)
  100.            case (ErrorCode shr 8) of
  101.                2 : writeln(' File not found.');
  102.                3 : writeln(' Path not found.');
  103.                4 : writeln(' Too many files open.');
  104.                5 : writeln(' File access denied.');
  105.              101 : writeln(' Disk write error.');
  106.              103 : writeln(' File not open');
  107.              150 : writeln(' Disk is write-protected')
  108.            end  (* case (ErrorCode shr 8) of                          *)
  109.          end
  110.   end         (* case (ErrorCode AND $FF) of                          *)
  111. END.
  112.  
  113.  
  114.