home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / alde_c / misc / func / advc / equipmnt.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-12-29  |  2.0 KB  |  102 lines

  1. #include <dos.h>
  2.  
  3. int commports()                       /* get number of serial ports */
  4. {
  5.    union REGS inregs;
  6.    union REGS outregs;
  7.    int86(0x11,&inregs,&outregs);
  8.    return((outregs.h.ah & 15) >> 1);
  9. }
  10.  
  11.  
  12.  
  13. int displaytype()                     /* get display type */
  14. {
  15.    union REGS inregs;
  16.    union REGS outregs;
  17.  
  18.    inregs.h.ah = 15;
  19.    int86(0x10,&inregs,&outregs);
  20.    return((outregs.h.al != 7));
  21. }
  22.  
  23.  
  24.  
  25. long drivespace(drv)                  /* get free space on a given drive */
  26.    char drv;
  27. {
  28.    union REGS inregs;
  29.    union REGS outregs;
  30.  
  31.    inregs.h.ah = 0x36;
  32.    if (drv == '@') inregs.h.dl = 0;
  33.    else inregs.h.dl = toupper(drv) - 'A' + 1;
  34.    intdos(&inregs,&outregs);
  35.    return((long) outregs.x.ax * outregs.x.bx * outregs.x.cx);
  36. }
  37.  
  38.  
  39.  
  40. char getdrive()                       /* get default drive */
  41. {
  42.    return((bdos(0x19,0,0) & 255)+'A');
  43. }
  44.  
  45.  
  46.  
  47. int joystick()                        /* see if there's a joystick */
  48. {
  49.    union REGS inregs;
  50.    union REGS outregs;
  51.    int86(0x11,&inregs,&outregs);
  52.    return((outregs.h.ah >> 4) & 1);
  53. }
  54.  
  55.  
  56.  
  57. int limmfree()                        /* get free pages of expanded memory */
  58. {
  59.    int freemem = 0;
  60.    union REGS inregs;
  61.    union REGS outregs;
  62.  
  63.    inregs.h.ah = 0x42;
  64.    int86(0x67,&inregs,&outregs);
  65.    if (!outregs.h.ah) freemem = outregs.x.bx;
  66.    return(freemem);
  67. }
  68.  
  69.  
  70.  
  71. int limmtotal()                       /* get total pages of expanded memory */
  72. {
  73.    int totalmem = 0;
  74.    union REGS inregs;
  75.    union REGS outregs;
  76.  
  77.    inregs.h.ah = 0x42;
  78.    int86(0x67,&inregs,&outregs);
  79.    if (!outregs.h.ah) totalmem = outregs.x.dx;
  80.    return(totalmem);
  81. }
  82.  
  83.  
  84.  
  85. int printports()                      /* get number of parallel ports */
  86. {
  87.    union REGS inregs;
  88.    union REGS outregs;
  89.    int86(0x11,&inregs,&outregs);
  90.    return(outregs.h.ah >> 6);
  91. }
  92.  
  93.  
  94.  
  95. int totalmem()                        /* get Kbytes of installed RAM */
  96. {
  97.    union REGS inregs;
  98.    union REGS outregs;
  99.    int86(0x12,&inregs,&outregs);
  100.    return(outregs.x.ax);
  101. }
  102.