How to get valid drive letters under Windows?

BlitzMax Forums/BlitzMax Programming/How to get valid drive letters under Windows?

Gangnam Style(Posted 2013) [#1]
Without disturbing drives (ie chdir-ing to them) of course.

Indeed I wrote a code to do this job:

Graphics 800, 600, 32

While Not AppTerminate ()

  Cls

  j = 0
  For i = 0 Until 24
    If ChangeDir ( Chr ( i + 67 ) + ":" )
      DrawText Chr ( i + 67 ) + ":", 0, j * 10
      j :+ 1
    End If
  Next

  Flip

Wend


I intentionally didn't include floppy disks and it works fine in full-screen. But in windowed modes, whenever I eject the DVD-ROM tray, a window is poped-up (abort/retry/fail). Is there an alternative way without using this change-directory-hack?


GfK(Posted 2013) [#2]
Get brucey's BAH.Volumes module - it has a GetDriveLetters() function (or something like that), which does exactly what you're trying to do.


Muttley(Posted 2013) [#3]
What GfK said...


xlsior(Posted 2013) [#4]
another vote for bah. Volumes

Also, note that while /most/ floppy drives are restricted to a and b historically, there is no technical reason for that anymore. I know people that have the z: drive associated with their floppy drive, as well as people that mapped a and b to non-floppy usb drives.
You really can't make assumptions without checking...


GfK(Posted 2013) [#5]
I know people that have the z: drive associated with their floppy drive
I'm surprised you know anybody that still has a floppy drive.


BlitzSupport(Posted 2013) [#6]
How about this?

Get list of valid drives (Windows-only)


BlitzSupport(Posted 2013) [#7]
This shouldn't give the 'insert disk' popup, but if it does, I have a way around it...


xlsior(Posted 2013) [#8]
I'm surprised you know anybody that still has a floppy drive.


Heck, we still have some of the old Sony MVC-FD digital cameras at the office that write straight to diskettes instead of memory card. 640x480 pixels, holds around a dozen pics or so per disk. Your tax dollars at work.

(At least the USB external floppy drives are twice as fast as the old internal ones)


xlsior(Posted 2013) [#9]
How about this?

Get list of valid drives (Windows-only)


Seems to work, and also includes network and SUBST-ed drive mappings.

For what it's worth: Brucey's bah.volumes can return some extra information, such as volume name, size, free space, and file system (which you can use to differentiate between hard drives and read-only optical media)