How to List Available Drives from Visual FoxProLast reviewed: September 28, 1995Article ID: Q135818 |
The information in this article applies to:
SUMMARYThis article shows by example how to determine which drive letters and types are available on your computer. The sample code in this article can be used to list the available drives and their types.
MORE INFORMATIONThe sample code in this article uses two API functions; DRIVETYPE() and WNetGetConnection():
Code SampleThe following code sample echos to the desktop drive letters A through Z, and displays the drive type of each. To run this example, open a new program (.prg) file, enter the following code, and run it: ** BEGIN CODE SAMPLE SET LIBRARY TO \VFP\FOXTOOLS.FLL & Register the FOXTOOLS Library DECLARE INTEGER WNetGetConnection IN win32api ; STRING lpszLocalName,; STRING lpszRemoteName,; INTEGER @ lpchBuffer && Declare the external WNetGetConnection ; API functionslpRemoteName = SPACE(254) && Initialize variables slen = LEN(slpRemoteName) && Initialize variables FOR I = 1 to 26 && Loop through drive letters A thru Z DRIVE = CHR(I + 64) DTYPE = DRIVETYPE(drive) && Determine drive type DO CASE CASE DTYPE = 0 && Non existent drives ? "Drive " + DRIVE + ": does not exist" CASE DTYPE = 1 && No root directory ? "Drive " + DRIVE + ": has no root directory" CASE DTYPE = 2 && Floppy drives ? "Drive " + DRIVE + ": is a floppy drive" CASE DTYPE = 3 && Hard drives ? "Drive " + DRIVE + ": is a local hard drive" CASE dtype = 4 && Removable or network drives iSuccess = WNetGetConnection(drive + ; ":",@slpRemoteName,@slen) IF iSuccess = 0 ? "Drive " + Drive + ": is a network" + ; " drive connected to " + LEFT(slpRemoteName,; ATC(chr(0),slpRemoteName) - 1) ENDIF CASE DTYPE = 5 && CD-ROM drives ? "Drive " + DRIVE + ": is a CD ROM drive" CASE DTYPE = 6 && RAM drives ? "Drive " + DRIVE + ": is a RAM drive" ENDCASEENDFOR ** END CODE SAMPLE
|
Additional reference words: 3.00 VFoxWin
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |