Announcement

Collapse
No announcement yet.

Get Drive List

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

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

    Thanks,
    Flick

    Leave a comment:


  • Russ Srole
    replied
    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

    Leave a comment:


  • Mel Bishop
    replied
    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.

    Leave a comment:


  • Bryan Flick
    started a topic Get Drive List

    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
Working...
X