Dec 062017
 
DRIVE is TP 5.0+ source code that contains a single routine, GetDiskClass, that attempts to classify the type of disk installed in a specified drive. It recognizes all of the most common disk types.
File DRIVE.ZIP from The Programmer’s Corner in
Category Pascal Source Code
DRIVE is TP 5.0+ source code that contains a single routine, GetDiskClass, that attempts to classify the type of disk installed in a specified drive. It recognizes all of the most common disk types.
File Name File Size Zip Size Zip Type
DRIVE.DOC 4312 1772 deflated
DRIVE.PAS 4264 1429 deflated

Download File DRIVE.ZIP Here

Contents of the DRIVE.DOC file


DRIVE.PAS - Routine for classifying disk drives
-----------------------------------------------

TurboPower Software
10/88
Version 1.0
Released to the public domain

Overview
------------------------------------------------------------------------------

DRIVE.PAS contains a single routine, GetDiskClass, that attempts to classify
the type of disk installed in a specified drive. It recognizes all of the most
common disk types, and it has been tested on a variety of machines running
virtually every major version of DOS from 2.0 to 4.0. Nevertheless, we feel
obliged to warn you that it uses an undocumented DOS function ($32), and that
it should therefore be used with some measure of caution.

We developed this routine for use in our own commercial software, specifically
an installation program that needs to know whether a particular drive contains
a floppy disk or some other form of removable media. You may find other uses
for it.

Using DRIVE
------------------------------------------------------------------------------

DRIVE.PAS contains the following type and procedure declarations:

type
DiskClass = (
Floppy360, Floppy720, Floppy12, Floppy144, OtherFloppy, Bernoulli,
HardDisk, RamDisk, SubstDrive, UnknownDisk, InvalidDrive);

This type defines the eight disk types that can be identified by DRIVE,
as well as several types indicating that a particular error occurred. The
meaning of each value is described briefly below:

Floppy360 A 360K, 5 1/4 floppy disk
Floppy720 A 720K, 3 1/2 floppy disk
Floppy12 A 1.2 meg, 5 1/4 floppy disk
Floppy144 A 1.44 meg, 3 1/2 floppy disk
OtherFloppy Another kind of floppy disk (e.g. a single-sided disk)
Bernoulli A Bernoulli drive
HardDisk Any hard disk
RamDisk A RAM disk created with VDISK.SYS, RAMDRIVE.SYS, etc.
SubstDrive A logical drive created by SUBST or ASSIGN
UnknownDisk Indicates that the drive could not be classified
InvalidDrive Indicates that the drive does not exist or isn't ready

function GetDiskClass(Drive : Char; var SubstDriveChar : Char) : DiskClass;
{-Return the disk class for the drive with the specified letter}

Given a drive letter ('A'..'Z'), this routine returns a value indicating
what kind of disk is installed in the specified drive. The possible return
values are described in the documentation for DiskClass.

There are two special cases that you should be aware of. First, the DOS
ASSIGN program allows you to treat one existing drive as another. For
example

ASSIGN B=C

would cause all disk I/O pertaining to drive B to be routed to drive C.
Similarly, the DOS SUBST program allows you to create a new logical drive
from an existing drive or directory. For example,

SUBST H: C:\TURBO

would allow you to refer to the directory "C:\TURBO" as drive H.

GetDiskClass is able to recognize both of these situations (though it
cannot distinguish between them). When it does, it will return 'SubstDrive'
as its function result, and it will pass back the letter of the actual
drive being used for the specified Drive in SubstDriveChar. In the case of
the second example above (involving SUBST), SubstDriveChar would be set to
'C' if the drive parameter were 'H'. Note that SubstDriveChar will always
be equal to Drive if the function result is something other than
SubstDrive.

Limitations
------------------------------------------------------------------------------

GetDiskClass cannot recognize the type of a floppy drive, only the type of the
disk that is in it (if any). For example, a 1.2 meg floppy drive will be
classified as Floppy360 if it has a 360K disk in it.

GetDiskClass does not currently recognize optical drives, nor does it
identify several rarely-used floppy disk types (single-sided floppies), for
example.

Credits
------------------------------------------------------------------------------

Thanks go to our many friends on the Borland Programmer's Forum A on CompuServe
who helped in the testing of this routine. There were too many testers to name
them all here. You know who you are, and so do we. We appreciate your help.


 December 6, 2017  Add comments

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)