GetDriveType Function

Declare Function GetDriveType Lib "kernel32.dll" Alias "GetDriveTypeA" (ByVal nDrive As String) As Long

Platforms: Win 32s, Win 95/98, Win NT

GetDriveType finds the type of disks a disk drive is/uses. This could be a fixed (hard) drive, a floppy drive, a CD-ROM drive, etc. The function returns the drive type. 0 means that an error occured. 1 means that the specified drive does not exist. Other return values are one of the following flags identifying the drive type:

DRIVE_CDROM = 5
A CD-ROM drive.
DRIVE_FIXED = 3
A hard drive.
DRIVE_RAMDISK = 6
A RAM disk.
DRIVE_REMOTE = 4
A network drive or a drive located on a network server.
DRIVE_REMOVABLE = 2
A floppy drive or some other removable-disk drive.
nDrive
The root directory of the drive to check, such as "c:\" or "a:\"

Example:

' Determine what type of drive D: is
Dim drivetype As Long  ' receives the drive type

drivetype = GetDriveType("d:\")  ' determine which kind of drive this is
If drivetype = 1 Then Debug.Print "Drive D:\ does not exist."
If drivetype = DRIVE_REMOVABLE Then Print "Drive D:\ is a removable-disk drive."
If drivetype = DRIVE_FIXED Then Print "Drive D:\ is a hard drive."
If drivetype = DRIVE_CDROM Then Print "Drive D:\ is a CD-ROM drive."
' etc.

Category: Files
Back to the index.


Go to Paul Kuliniewicz's Home Page.
E-mail: rogue953@hotmail.com
This page is at http://skyscraper.fortunecity.com/transmission/45/api/g/getdrivetype.html