home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / reboot2.zip / REBOOT.C < prev    next >
C/C++ Source or Header  |  1992-06-22  |  1KB  |  50 lines

  1. /* Reboot/2 version 1.0 Nick Bethmann, 22 Jun 92 */
  2.  
  3. #define  INCL_DOSFILEMGR
  4. #define  INCL_DOSDEVICES
  5.  
  6. #include <OS2.h>
  7. #include <stdlib.h>
  8. #include <string.h>
  9.  
  10. int _cdecl main( void )
  11. {
  12.  
  13.    HFILE    handle;
  14.    short    action;
  15.    unsigned err;
  16.  
  17.    /*
  18.     *  Open the device driver.
  19.     */
  20.    err = DosOpen( "\\DEV\\DOS$",
  21.                   &handle,
  22.                   &action,
  23.                   0L,
  24.                   FILE_NORMAL,
  25.                   FILE_OPEN,
  26.                   OPEN_SHARE_DENYNONE, 0L );
  27.    if ( err )
  28.    {
  29.       char buffer[80];
  30.       char val[6];
  31.          /* yes, printf would be easier, but MUCH bigger */
  32.       strcpy( buffer, "\nDOS$ device open failed. err " );
  33.       strcat( buffer, itoa(err, val, 10) );
  34.       strcat( buffer, "\n" );
  35.       DosWrite( 1, buffer, strlen(buffer), &err );
  36.       return( 2 );
  37.    }
  38.  
  39.    /*
  40.     *  Shutdown the filesystem.
  41.     */
  42.    DosShutdown( 0 );
  43.  
  44.    /*
  45.     *  Reboot the system, using Magic cookies found in boot.com 
  46.     */
  47.    DosDevIOCtl( NULL, NULL, 0xAB, 0xD5, handle );
  48.  
  49. }
  50.