Windows API Guide: GetClassName Function


Declare Function GetLogicalDrives Lib "kernel32.dll" () As Long

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

GetLogicalDrives determines all the valid logical drives on the computer. Logical drives are any drives assigned a one-letter name (such as A: or C:). The return value is a collection of single-bit flags identifying the drives found. Perform a binary And between the return value and increasing powers of 2 to determine all of the drives. For example, And it with 1 to see if drive A: exists, with 2 for B:, 4 for C:, 8 for D:, etc. (See the example for a demonstration.)

Example:

' Tell the user which drives exist on the computer.  Note how this example ' only checks up to drive D:, but it does establish the necessary pattern to use in general. Dim driveflags As Long  ' receives the flags identifying valid drives ' Get the valid logical drives on the computer. driveflags = GetLogicalDrives() ' Test the returned value to see if drives A: through D: exist. If (driveflags And 1) = 1 Then Debug.Print "Drive A: exists." If (driveflags And 2) = 2 Then Debug.Print "Drive B: exists." If (driveflags And 4) = 4 Then Debug.Print "Drive C: exists." If (driveflags And 8) = 8 Then Debug.Print "Drive D: exists." ' And so on....

See Also: GetLogicalDriveStrings
Category: Files

Go back to the alphabetical Function listing.
Go back to the Reference section index.


This page is copyright © 2000 Paul Kuliniewicz. Copyright Information.
Go back to the Windows API Guide home page.
E-mail: vbapi@vbapi.com Send Encrypted E-Mail
This page is at http://www.vbapi.com/ref/g/getlogicaldrives.html



Windows API Guide
Windows API Guide - Reference - Volume 1: Version 3.0 For the MS-DOS and PC-DOS Operating Systems
ISBN: B001V0KQIY
EAN: N/A
Year: 1998
Pages: 610

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net