Retrieve Information About Available Drives
You’d like to be able to gather specific information about the disk drives in your computer: for example, how large they are, how much space is free, whether they’re local or remote, and whether they’re removable or not. Access does not provide this information. Is it available using a Windows API function?
The Windows API provides three functions that you can use to extract information about the drives in your computer: GetLogicalDriveStrings, which returns a string containing a list of all the logical drives; GetDriveType, which returns information about the specified drive; and GetDiskFreeSpace, which returns information about the total and free disk space for a specified drive.
Load and run frmDiskSpace from
form, shown in Figure 11-14, contains a list box with
information about all the logical drives in your system. To fill the
list box, the example code walks through all the drives returned from
a call to GetLogicalDriveStrings, calling the
other two functions for each drive.
Figure 11-14. frmDiskSpace shows information about all the installed drives
To use these functions in your own applications, follow these steps:
Import the modules basDiskInfo and basToken from
To call the functions, use the information in Table 11-12. Each function takes only a single parameter, the drive to be interrogated. ...