Databases Reference
In-Depth Information
TypeOfDrive = "Network Drive"
Case 4
TypeOfDrive = "CD Rom"
Case Else
TypeOfDrive = "Unknown Drive Type = " &
SpecDrive.DriveType
End Select
Case False
TypeOfDrive = SpecDrive.DriveType
End Select
'We are done here
Exit Function
'Error Handling
Drive_Unavailable:
TypeOfDrive = "Drive Not Available!"
End Function
Two parameters are passed to the TypeOfDrive function. The DriveType property of the
Drive Object returns an integer that represents the type of drive being queried. The TypeOfDrive
function is capable of returning either the numerical representation of the drive (as a string) or a
string description of the drive that is queried utilizing the passed parameter Drive$ . The passed
parameter ReturnName determines if the numerical representation or the string description of
the queried drive is returned. A sample application utilizing the two preceding functions has been
created, which can be run by selecting from the menu A DA -> Chapter 2 -> Drive S tatus Example.
Figure 2.23 shows how these functions can be utilized to determine when a CD-ROM drive is
unavailable (usually from not having a disk in the tray). Figure 2.24 shows how the status of a
network drive can also be determined utilizing the preceding two functions.
Although the preceding two functions provide the most key and critical attributes required for
successful I/O operations, there are some other useful properties of drives, directories, and files that can
also be obtained. When a drive is available for use, it is always nice to be able to check how much free
space is available and what the total capacity of the drive is. The next two functions provide this capability.
Function DriveFreeSpace(ByVal Drive$) As Single
Dim FSO As FileSystemObject
Dim SpecDrive As Drive
On Error GoTo Drive_Unavailable
FIGURE 2.23 The drive status example on a CD-ROM drive without a disk.
Search WWH ::




Custom Search