[python-win32] List of drives / removable drives

Howard Lightstone howard at eegsoftware.com
Thu Dec 21 01:17:42 CET 2006


> 
> 
> Is there a way to differentiate between floppy, network, hard drive, removable (aka USB flash) 
> drives? though Pythonwin?
> 
> My searches came up with Tim Golden's mapped drives, which is somewhat helpful, but not 
> particular to my needs.
> http://tgolden.sc.sabren.com/python/win32_how_do_i/show_mapped_drives.html
> 
> win32api.GetVolumeInformation doesn't return anything specific- other than 'FAT' which is used 
> on a floppy, but somehow
> I was expecting something a little more specific.
How about (untried but ...)

drivebits=win32file.GetLogicalDrives()
for d in range(1,26):
        mask=1 << d
        if drivebits & mask:
                # here if the drive is at least there
                drname='%c:\\' % chr(ord('A')+d)
                t=win32file.GetDriveType(drname)
                if t == win32file.DRIVE_REMOVABLE:

Or whatever DRIVE_* defined values there are in win32file
DRIVE_CDROM 
DRIVE_FIXED 
DRIVE_NO_ROOT_DIR 
DRIVE_RAMDISK 
DRIVE_REMOTE 
DRIVE_REMOVABLE 
DRIVE_UNKNOWN 

--
Howard Lightstone
www.eegsoftware.com
howard at eegsoftware.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-win32/attachments/20061220/e19693f8/attachment.htm 


More information about the Python-win32 mailing list