Retrieve Information About Available Drives
Problem
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?
Solution
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 11-12.MDB
. This
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
11-12.MDB
.To call the functions, use the information in Table 11-12. Each function takes only a single parameter, the drive to be interrogated. ...
Get Access Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.