home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / SHUTDOWN.ZIP / SHUTDOWN.C next >
C/C++ Source or Header  |  1990-01-21  |  2KB  |  50 lines

  1. /* for use with OS/2 1.2 */
  2. /* compile with cl shutdown.c */
  3. /* simple with the right #include files, darn difficult otherwise.
  4. so here is the declaration for shutdown, very handy when using
  5. alternate PROTSHELLs with High Performance File System */
  6.  
  7. extern unsigned int far pascal DosShutdown(unsigned long reserved);
  8. extern unsigned int far pascal DosGetVersion(unsigned int far * version);
  9. /* (high byte = major version number, low byte = minor version number ); */
  10.  
  11. /* now why can't MSC include files be so straightforward? */
  12.  
  13. char shutdownmessage[] = "\n\
  14. DosShutdown is an OS/2 kernel function which closes down the file\n\
  15. system and ends all processes. Proceed with shutdown? (y,n) ";
  16.  
  17. char shutdownmessage2[] = "\n\n\
  18. When all disk activity has stopped turn the power off or reboot the\n\
  19. computer with <ctl-alt-del> "; 
  20.  
  21. main()
  22. {
  23.     char c;
  24.     unsigned int Version;
  25.     unsigned char MajorVersionNumber;
  26.     unsigned char MinorVersionNumber;
  27.  
  28.     DosGetVersion((unsigned int far *) &Version);
  29.     MajorVersionNumber = (Version >> 8) / 10;
  30.     MinorVersionNumber  = (Version & 0x00FF) / 10;
  31.     printf("\nThe OS/2 version number is %d.%d\n",
  32.         MajorVersionNumber,MinorVersionNumber);
  33.  
  34.     if(MinorVersionNumber < 2)
  35.     {
  36.         printf("Shutdown is not available with this version of OS/2");
  37.         exit(1);
  38.     }
  39.  
  40.     printf("%s",shutdownmessage);
  41.     c = getch();
  42.     if(c == 'y' || c == 'Y')
  43.     {
  44.         printf("%s",shutdownmessage2);
  45.         DosShutdown(0L);
  46.     }
  47.     printf("\n\nFile system not shutdown");
  48.  
  49. }
  50.