home *** CD-ROM | disk | FTP | other *** search
/ PC Shareware 1999 March / PCShareware-3-99.iso / IMPLE / DJGPP.RAR / DJGPP2 / CRCLOCKS.ZIP / MYPROG.CPP < prev    next >
C/C++ Source or Header  |  1997-07-30  |  2KB  |  40 lines

  1. // MYPROG.CPP - An example of how to integrate CRCLock v2.4 into your own
  2. // programs. Usage couldn't be simpler, just add the "crclock.h" header
  3. // file to your program and CRCLock is ready to be used in either C or C++
  4. // mode.
  5. // To compile this program use "tcc -ml -2 myprog.cpp clcodel.obj"
  6. // The "-ml" option on the command line specifies the memory model that you
  7. // wish to use with CRCLock. The the terminating later on the Mobile Code
  8. // name is the memory model that, that specific piece of code was created
  9. // with. e.g. For the example above the terminating letter is "l', therefore
  10. // that mobile code is in the Large memory model.
  11. // If you wanted to compile in the small memory model, then you would type
  12. // "tcc -ms myprog.cpp clcodes.obj"
  13. // Remember to include the correct model code in your project file, if you
  14. // are using Turbo C++ or other compiler project modes.
  15.  
  16. #include <stdio.h>
  17. #include <process.h>
  18. #include "crclock.h"
  19.  
  20. int main(int argc, char *argv[])
  21. {
  22.  int status=0, i=0;
  23.  
  24.  if(argc>1) printf("Ignoring Extra Parameters.\n");
  25.  
  26.  // CRCLock Runs here as the FIRST function in the file.
  27.  printf("Scanning File Integrity.... ");
  28.  status=CRCLock(argv[0]);
  29.  if(status==0x00) printf("OK.\n");
  30.  if(status==0x01) {printf("Failed. Internal Tampering Detected.\n"); exit(1);}
  31.  if(status==0x02) {printf("Failed. Filename Changed.\nCosmetic Tampering Detected.\n"); exit(1);}
  32.  // CRCLock has finished, if the code reaches here then there are no problems.
  33.  
  34.  // Your program can now run quite happily.
  35.  printf("\nMYPROG.EXE - Example usage of CRCLock v2.4. (C) NE Body.\n");
  36.  for(i=0; i<=1000; i++) printf("MyProg is running: %03d.\r",i);
  37.  printf("\n");
  38.  
  39.  return 0;
  40. }