home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / pascal / library / dos / bix / cluster.pas < prev    next >
Pascal/Delphi Source File  |  1986-08-04  |  2KB  |  65 lines

  1.   {  I'm not sure if this is the version I posted elsewhere, but
  2.      at any rate this program uses MS-DOS/PC-DOS calls to
  3.      determine the disk/diskette allocation information for
  4.      your disk drives.
  5.  
  6.      By itself, it's only useful to show the cluster sizes that
  7.      your version of DOS establishes.  However, you may find a
  8.      use for portions of the code within your own programs in
  9.      order to determine allocation data.
  10.  
  11.      Scavenge the code any way you like.                      }
  12.  
  13. Program AllocationTableInformation;
  14. Type
  15.    DOSRegs  = record
  16.      Case Integer of
  17.        0: (ax, bx, cx, dx, bp, si, di, ds, es, Flags : Integer);
  18.        1: (al, ah, bl, bh, cl, ch, dl, dh            : Byte   );
  19.        End;
  20. Var
  21.   Registers   : DOSRegs;
  22.   ClusterSize : Real;
  23.   DiskSize    : Real;
  24.  
  25. Begin
  26.   LowVideo;
  27.   ClrScr;
  28.  
  29.   Fillchar (Registers, sizeof(DOSRegs), 00);
  30.   Registers.AH := $30;
  31.   Registers.DS := DSeg;
  32.   MsDOS (registers);
  33.  
  34.   If Registers.AL = 0 then
  35.      Begin
  36.        Writeln; Writeln;
  37.        Writeln ('Sorry, this pgm. only works with DOS 2.0 or higher');
  38.        Writeln; Writeln;
  39.        Halt;
  40.        End;
  41.  
  42.   Fillchar (Registers, sizeof(DOSRegs), 00);
  43.   Registers.AH := $1B;
  44.   Registers.DS := DSeg;
  45.   MsDOS (registers);
  46.   Writeln; Writeln;
  47.   Writeln ('':10, 'Allocation Table Information, Default Drive:');
  48.   Writeln;
  49.  
  50.   With Registers Do
  51.        Begin
  52.          Writeln ('# of clusters on disk..........', DX : 5);
  53.          Writeln ('Sectors per cluster............', AL : 5);
  54.          Writeln ('Sector size (bytes)............', CX : 5);
  55.          Writeln;
  56.          ClusterSize := (AL * CX);
  57.          DiskSize    := (ClusterSize * DX);
  58.          Writeln ('Size of each cluster...........', ClusterSize:10:0);
  59.          Writeln ('Total disk space...............', DiskSize   :10:0);
  60.          End;
  61.  
  62.   Writeln; Writeln;
  63.   Writeln; Writeln;
  64.   End.
  65.