home *** CD-ROM | disk | FTP | other *** search
/ Power CD-ROM!! 7 / POWERCD7.ISO / prgmming / exeval_c / exedemow.c < prev    next >
C/C++ Source or Header  |  1994-07-16  |  2KB  |  53 lines

  1. /* WINDOWS VERSION */
  2.  
  3. /* This sample program demonstrates the use of the .EXE file validation */
  4. /* system. This program simply checks whether its .EXE file is valid,   */
  5. /* and displays a message accordingly. To rebuild this file, create a   */
  6. /* "makefile" / "project file" that includes exedemo.c and exevalid.c.  */
  7. /* After compiling the .EXE file, use the exestamp program to create a  */
  8. /* valid hash stamp in the .EXE file.                                   */
  9.  
  10. #include "windows.h"
  11.  
  12. /* Include the EXEValid header file. */
  13. #include "exevalid.h"
  14.  
  15. /* Program execution begins here. */
  16. int PASCAL WinMain(HINSTANCE hinstCurrent,
  17.                    HINSTANCE hinstPrevious,
  18.                    LPSTR lpszCmdLine,
  19.                    int nCmdShow)
  20. {
  21.    char szEXEFileName[100];
  22.  
  23.    if(!GetModuleFileName(hinstCurrent, szEXEFileName, sizeof(szEXEFileName)))
  24.    {
  25.       MessageBox(NULL, "Unable to determine .EXE file name.",
  26.          ".EXE Validation Demo", MB_OK);
  27.    }
  28.  
  29.    /* Validate EXE and act accordingly. */
  30.    switch(ValidateEXE(szEXEFileName))
  31.    {
  32.       case kInvalid:
  33.            MessageBox(NULL,
  34.               "EXE file does not have a valid hash stamp; aborting.",
  35.             ".EXE Validation Demo", MB_OK);
  36.          return(1);
  37.       case kGeneralFailure:
  38.            MessageBox(NULL,
  39.               "Internal error - not enough system resources available.",
  40.             ".EXE Validation Demo", MB_OK);
  41.          return(1);
  42.    }
  43.    
  44.    /* Program execution will only get to this point if .EXE is valid. */
  45.    MessageBox(NULL, "EXE file is valid, proceeding normally.",
  46.       ".EXE Validation Demo", MB_OK);
  47.  
  48.    /* Exit program. */   
  49.    return(0);
  50. }
  51.  
  52.  
  53.