home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / snip9707.zip / OS2_BOOT.C < prev    next >
C/C++ Source or Header  |  1997-07-05  |  1KB  |  57 lines

  1. /* +++Date last modified: 05-Jul-1997 */
  2.  
  3. /*
  4. **  OS/2 Reboot function
  5. **
  6. **  public domain by Mark Kimes
  7. */
  8.  
  9. #if defined(__MSDOS__) || defined(MSDOS)
  10.  #error OS2_BOOT.C is NOT intended for DOS programs ...
  11. #endif
  12.  
  13. #define INCL_DOS
  14.  
  15. #include <os2.h>
  16. #include <stdlib.h>
  17. #include <stdio.h>
  18.  
  19. int main(void)
  20. {
  21.       HFILE  hf;
  22. #ifdef __32BIT__
  23.       ULONG  dummy;
  24.       ULONG  rc;
  25. #else
  26.       USHORT dummy;
  27.       USHORT rc;
  28. #endif
  29.  
  30.       rc = DosOpen("DOS$",&hf,&dummy,0L,FILE_NORMAL,FILE_OPEN,
  31.             OPEN_ACCESS_WRITEONLY | OPEN_SHARE_DENYNONE |
  32.             OPEN_FLAGS_FAIL_ON_ERROR,NULL);
  33.       if(!rc)
  34.       {
  35.             /* Flush the caches           */
  36.  
  37.             DosShutdown(1);
  38.  
  39.             /* Shut down the file system  */
  40.  
  41.             DosShutdown(1);
  42.             rc = DosShutdown(0);
  43.             if(!rc)
  44.             {
  45.                   /* reboot machine */
  46.                   
  47. #ifdef __32BIT__
  48.                   rc = DosDevIOCtl(hf,0xd5,0xab,NULL,0,NULL,NULL,0,NULL);
  49. #else
  50.                   rc = DosDevIOCtl(NULL,NULL,0xab,0xd5,hf);
  51. #endif
  52.                   DosClose(hf);
  53.             }
  54.       }
  55.       return rc;
  56. }
  57.