List of disk drives on Windows?

Mike Driscoll kyosohma at gmail.com
Tue May 20 15:58:40 EDT 2008


On May 20, 2:45 pm, Tim Golden <m... at timgolden.me.uk> wrote:
> Bob Greschke wrote:
> > This MUST have been asked before, but I can't seem to Google the right
> > thing.  How can I get a list of drives on a Windows box, like ["C:\",
> > "D:\"], like I can if I do something like listdir("/Volumes") on a Mac?
>
> A couple of options to get the ball rolling:
>
> 1) win32api.GetLogicalDriveStrings()


I gave this a go to see how it worked and ti gave me this:

'A:\\\x00C:\\\x00D:\\\x00G:\\\x00I:\\\x00L:\\\x00P:\\\x00Q:\\\x00R:\\
\x00U:\\\x00X:\\\x00Y:\\\x00Z:\\\x00'

Not exactly what I expected. Do I have to parse out the "\\\x00"
myself or is there an information level switch I should add?

>
> 2)http://timgolden.me.uk/python/wmi_cookbook.html#find-drive-types


This works as advertised. I was actually going to post that, but you
beat me to it.  :)

>
> TJG


Mike



More information about the Python-list mailing list