how to enumerate all drives on Win32?
sholden at holdenweb.com
Tue May 1 16:00:34 CEST 2001
"Wolfgang Strobl" <ws at mystrobl.de> wrote in message
news:r1ctetgsnk915avfu6c459s3hv3lqghep6 at 4ax.com...
> On Mon, 30 Apr 2001 19:11:09 GMT, "Steve Holden" <sholden at holdenweb.com>
> wrote in <hNiH6.47579$qc2.12456011 at typhoon.southeast.rr.com>:
> ><skip at pobox.com> wrote in message
> >news:mailman.988655383.28858.python-list at python.org...
> >> For a file/directory browser I need to be able to traverse all mounted
> >> filesystems. This is no problem on Unix systems, because we have the
> >> mount(2) system call and thus have a single directory tree rooted at /.
> >> Alas, Windows (once again) is broken in this regard. I need to know
> >> enumerate all the drive letters that have something mounted on them. I
> >> didn't see anything in the ntpath module that looked like it would do
> >> trick. Any suggestions?
> >> Thanks,
> or, sligthly extended:
> import win32api,string
> import win32file,win32wnet
> for d in drives:
> if d:
> print d,"is",drivetype[win32file.GetDriveType(d)],
> if win32file.GetDriveType(d)==win32file.DRIVE_REMOTE:
> print "on",win32wnet.WNetGetUniversalName(d),
> That snipped produces
> A:\ is removable
> C:\ is fixed
> D:\ is fixed
> M:\ is cdrom
> N:\ is cdrom
> Q:\ is fixed
> U:\ is remote on \\wbox\import\
Interesting. I presume my Win32wnet is out of date, since on my system it
a:\ is removable
c:\ is fixed
d:\ is fixed
h:\ is cdrom
r:\ is remote on
Traceback (most recent call last):
File "windrives.py", line 19, in ?
More information about the Python-list