home *** CD-ROM | disk | FTP | other *** search
/ Media Share 13 / mediashare_13.zip / mediashare_13 / ZIPPED / PROGRAM / SNPD9404.ZIP / TASKER.C < prev    next >
C/C++ Source or Header  |  1994-04-03  |  3KB  |  128 lines

  1. /*
  2. **  Tasker.C
  3. **
  4. **  public domain by David Gibbs
  5. */
  6.  
  7. struct ts_os_ver t_os_ver[TOT_OS];
  8. int t_os_type;
  9. int t_os;
  10.  
  11. const char *t_os_name[TOT_OS] = {
  12.       "DOS",
  13.       "OS/2 DOS",
  14.       "DESQview",
  15.       "Windows Std",
  16.       "Windows 386"
  17.       };
  18.  
  19. int get_os (void)
  20. {
  21.       union REGS t_regs;
  22.  
  23.       t_os_type = 0;
  24.       t_os = 0;
  25.  
  26.       /* test for DOS or OS/2 */
  27.  
  28.       if (_osmajor < 10)
  29.       {
  30.             t_os_ver[DOS].maj = _osmajor;
  31.             t_os_ver[DOS].min = _osminor;
  32.             t_os_type = t_os_type | is_DOS;
  33.       }
  34.       else
  35.       {
  36.             t_os_type = t_os_type | is_OS2;
  37.             t_os_ver[OS2].maj = _osmajor/10;
  38.             t_os_ver[OS2].min = _osminor;
  39.       }
  40.  
  41.       /* test for Windows */
  42.  
  43.       t_regs.x.ax = 0x4680;
  44.       int86(0x2F, &t_regs, &t_regs);
  45.  
  46.       if (t_regs.x.ax == 0x0000)
  47.       {
  48.             t_os_ver[WINS].maj = 3;
  49.             t_os_ver[WINS].min = 0;
  50.             t_os_type = t_os_type | is_WINS;
  51.       }
  52.       else
  53.       {
  54.             t_regs.x.ax = 0x1600 ;
  55.             int86(0x2F, &t_regs, &t_regs);
  56.  
  57.             switch (t_regs.h.al)
  58.             {
  59.             case 0x00 :
  60.             case 0x80 :
  61.             case 0x01 :
  62.             case 0xFF :
  63.                   break;
  64.  
  65.             default   :
  66.                   t_os_type = t_os_type | is_WIN3;
  67.                   t_os_ver[WIN3].maj = t_regs.h.al;
  68.                   t_os_ver[WIN3].min = t_regs.h.ah;
  69.                   break ;
  70.             }  /* endswitch  */
  71.       } /* endif */
  72.  
  73.       /* Test for DESQview */
  74.  
  75.       t_regs.x.cx = 0x4445;     /* load incorrect date */
  76.       t_regs.x.dx = 0x5351;
  77.       t_regs.x.ax = 0x2B01;     /*  DV set up call     */
  78.  
  79.       intdos(&t_regs, &t_regs);
  80.       if (t_regs.h.al != 0xFF)
  81.       {
  82.             t_os_type = t_os_type | is_DV;
  83.             t_os_ver[DV].maj = t_regs.h.bh;
  84.             t_os_ver[DV].min = t_regs.h.bl;
  85.       }
  86.  
  87.       if(t_os_type & is_DOS)
  88.             t_os = DOS;
  89.  
  90.       if(t_os_type & is_WINS)
  91.             t_os = WINS;
  92.  
  93.       if(t_os_type & is_WIN3)
  94.             t_os = WIN3;
  95.  
  96.       if(t_os_type & is_DV)
  97.             t_os = DV;
  98.  
  99.       if(t_os_type & is_OS2)
  100.             t_os = OS2;
  101.  
  102.       return(t_os-1);
  103.  
  104. }
  105.  
  106. void t_slice(void)
  107. {
  108.       union REGS t_regs;
  109.     
  110.       switch (t_os)
  111.       {
  112.       case DOS  :
  113.             break;
  114.  
  115.       case OS2  :
  116.       case WIN3 :
  117.       case WINS :
  118.             t_regs.x.ax = 0x1680;
  119.             int86(0x2f,&t_regs,&t_regs);
  120.             break;
  121.  
  122.       case DV   :
  123.             t_regs.x.ax = 0x1000;
  124.             int86(0x15,&t_regs,&t_regs);
  125.             break;
  126.       } /* switch(t_os) */
  127. }
  128.