How to Find All Available Hard and Network Disk Drives

Last reviewed: April 29, 1996
Article ID: Q103579
The information in this article applies to:
  • Microsoft Visual FoxPro for Windows, version 3.0
  • Microsoft FoxPro for MS-DOS, versions 2.0, 2.5, and 2.5a
  • Microsoft FoxPro for Windows, versions 2.5 and 2.5a

SUMMARY

FoxPro does not have a function to return the available disk drives to the system.

The program below, which works with both FoxPro for MS-DOS and FoxPro for Windows, finds the available hard and network disk drives.

MORE INFORMATION

The following program creates an array and populates it with the available hard and network disk drives. It does not check for floppy disk drives.

NOTE: If this program is used with FoxPro for Windows and there is a CD-ROM drive on the local machine and but no CD in the drive, Windows will return a system error message. This error does not occur with FoxPro for MS-DOS. Instead, the CD-ROM drive is returned.

**Start of Program**

     *SET ERROR HANDLER TO myerror
     ON ERROR DO myerror WITH ERROR()
     PUBLIC availdrive
     arrcount=1
     drive=.T.
     letter=CHR(67)
     def=SYS(5)+SYS(2003)

     DO WHILE letter<="Z"
          SET DEFAULT TO (letter)+":"
          IF drive
               DIMENSION availdrive(arrcount)
               availdrive(arrcount)=letter+":"
               arrcount=arrcount+1
               letter=CHR(ASC(LETTER)+1)
          ELSE
               letter=CHR(ASC(LETTER)+1)
               drive=.T.
          ENDIF
     ENDDO
     SET DEFAULT TO (def)

     PROCEDURE myerror
     PARAMETERS errnum

     DO CASE
          CASE errnum=202
               drive=.F.
          CASE errnum=1907
               drive=.F.
     ENDCASE

**End of Program**


Additional reference words: VFoxWin 3.00 FoxDos FoxWin 2.00 2.50 2.50a
KBCategory: kbprg kbcode
KBSubcategory: FxnetworkGeneral


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: April 29, 1996
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.