Announcement

Collapse
No announcement yet.

Get Drive List

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Get Drive List

    Does anyone know how to get a list of available drives in Windows XP? With this list, is there a way to get a description for the drive, such as 3.5 floppy, hard drive, DVD-ROM drive, USB drive, etc.?

    I looked at CHDRIVE, DIR$, and through the Windows API on MSDN and can't seem to find the proper PB or Win32 API function to use.

    Any help is appreciated.

    Thanks,
    Flick

  • #2
    Code:
    for drive = 65 to 90                        
                                                    
    if getdrivetype(chr$(drive) + ":\") = 5 then
    incr i                                      
    redim preserve a(i)                         
    a(i) = chr$(drive) + ":"                    
    end if                                      
    next drive
    5 = CD
    Can't remember what other numbers mean. You'll have to experiment.
    There are no atheists in a fox hole or the morning of a math test.
    If my flag offends you, I'll help you pack.

    Comment


    • #3
      Flick,

      I've used this in the past. I return a string with "|" as a separator and filter out the types I don't want. You will want to change that part for your purposes.

      Code:
      FUNCTION GetDriveLetters() AS STRING
          REGISTER i&
          DIM Drv AS ASCIIZ *4
          DIM C$
          DIM Res AS LONG
          DIM Ldrv AS DWORD
          DIM Drvlist(26) AS STRING
      
          ' get the list of drive as a bitmap
          Ldrv= GetLogicalDrives()      ' win32api
          FOR I = 2 TO 26
              IF BIT(ldrv,I)=1 THEN Drvlist(I)=CHR$(65+I&,":\")
          NEXT
          'look at the list and only return fixed (hard drives) & remote (network mapped drives)
          FOR I= 2 TO 26
              drv = drvlist(I)
              IF drv = "" THEN ITERATE
              res = GetDriveType(drv)      ' win32api
              IF res& = %DRIVE_FIXED OR Res& = %DRIVE_REMOTE THEN c$ = c$ + drv + "|"
          NEXT
          FUNCTION = c$
      END FUNCTION
      Russ
      "There are two novels that can change a bookish fourteen-year old's life: The Lord of the Rings and Atlas Shrugged. One is a childish fantasy that often engenders a lifelong obsession with its unbelievable heroes, leading to an emotionally stunted, socially crippled adulthood, unable to deal with the real world. The other, of course, involves orcs." - John Rogers

      Comment


      • #4
        Thank you both! The code snippets got me in the right direction and were exactly what I was looking for.

        Thanks,
        Flick

        Comment

        Working...
        X