How to Find All Available Hard and Network Disk Drives

ID: Q103579

2.00 2.50 2.50a | 2.50 2.50a 3.00

MS-DOS          | WINDOWS

The information in this article applies to:

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: KBSubcategory: FxnetworkGeneral

Keywords          : kbcode FxnetworkGeneral 
Version           : 2.00 2.50 2.50a | 2.50 2.50a 3.0
Platform          : MS-DOS WINDOWS

Last Reviewed: May 22, 1998