home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / cprog / actlib12.zip / TOOLS.ZIP / DENSITY.C < prev    next >
C/C++ Source or Header  |  1993-02-25  |  810b  |  40 lines

  1. /*  Copyright (C) 1993   Marc Stern  (internet: stern@mble.philips.be)  */
  2.  
  3. #include "tools.h"
  4. #include <dos.h>
  5.  
  6.  
  7. /***
  8.  *
  9.  *  Function   :    getdensity
  10.  *
  11.  *  Topics     :    Returns the density of a floppy drive.
  12.  *
  13.  *  Parameters :    in    int drive         0 = A:, 1 = B:
  14.  *
  15.  *  Return code:    density in Kb (360, 720, 1200, 1440)
  16.  *                  0 if invalid drive
  17.  ***/
  18.  
  19. int getdensity( int drive )
  20.  
  21. { union REGS regs, outregs;
  22.   
  23.   regs.h.ah = 8;
  24.   regs.h.dl = drive;
  25.   int86( 0x13, ®s, &outregs );     /* sometimes fails first time */
  26.   int86( 0x13, ®s, &outregs );
  27.   switch( outregs.h.bl )
  28.       {
  29.           case 1 :  return 360;
  30.  
  31.       case 2 :  return 1200;
  32.  
  33.       case 3 :  return 720;
  34.  
  35.       case 4 :  return 1440;
  36.  
  37.       default:  return 0;
  38.     }
  39. }
  40.