home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The World of Computer Software
/
World_Of_Computer_Software-02-387-Vol-3of3.iso
/
m
/
msh_ut11.zip
/
DSKFREE.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1992-05-09
|
2KB
|
99 lines
PROGRAM DskFree;
{ Support-Program for MiShell, JP 92 }
{ Write just capacity and free space of }
{ drive in (specified or default) file }
{ Call: dskfree <drivespec> [<targetfile>] }
USES DOS;
CONST TargetFile = 'DSKFREE.TXT'; { Change for your drive }
VAR Thousands, Decimal : CHAR;
PROCEDURE OSInit; { Get Thousands/Decimal-Separator from DOS }
VAR
Regs : REGISTERS;
CountryBuf : ARRAY [0..$21] OF CHAR;
Major : BYTE;
BEGIN
WITH regs DO
BEGIN
Ah := $30;
MSDOS (Regs);
Major := Al;
AX := $3800;
DS := SEG (CountryBuf);
DX := OFS (CountryBuf);
INTR ($21, Regs);
IF Major >= 3 THEN
BEGIN
Thousands := CountryBuf [$7];
Decimal := CountryBuf [$9];
END
ELSE
BEGIN
Thousands := CountryBuf [$04];
Decimal := CountryBuf [$06];
END;
END;
END;
PROCEDURE diskpar(drive : Byte; VAR capacity, freespace : LONGINT);
VAR { DRIVE : 0 = Current Drive }
regs : Registers; { 1 = Drive A }
BEGIN { 2 = Drive B }
WITH regs DO { and so on }
BEGIN
ax := $3600;
dx := drive;
MsDos(regs);
IF (ax <> $ffff) THEN
BEGIN
capacity := ax*cx;
freespace := capacity*bx;
capacity := capacity*dx;
END
ELSE
BEGIN
capacity := 0;
freespace := 0;
END;
END;
END;
PROCEDURE Formatted (l : LONGINT; VAR s : STRING; len : BYTE);
VAR i : INTEGER;
BEGIN
STR(l, s);
i := length(s) - 3;
WHILE (i>0) DO
BEGIN
Insert(Thousands, s, i + 1);
DEC(i, 3);
END;
WHILE Length(s)<len DO
s := ' ' + s;
END;
VAR Fil : TEXT;
kap, fre : LONGINT;
i : BYTE;
drv : STRING[2];
t, f : STRING;
BEGIN
IF ParamCount>0 THEN
BEGIN
OSInit;
drv := Copy(ParamStr(1), 1, 1) + ':'; drv[1] := Upcase(Drv[1]);
diskpar(ORD(drv[1]) - ORD('A') + 1, kap, fre);
Formatted(kap, t, 13);
Formatted(fre, f, 13);
IF ParamStr(2)<>'' THEN
ASSIGN(Fil, paramStr(2))
ELSE
ASSIGN(Fil, TargetFile);
REWRITE(Fil);
WRITELN(Fil, t, ' bytes in ', drv);
WRITELN(Fil, f, ' bytes free');
CLOSE(Fil);
END;
END.