"Bengt Richter" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]
> On 14 Jan 2006 16:52:33 -0800, "Claude Henchoz" <[EMAIL PROTECTED]> wrote:
>
>>Hi
>>
>>Is there any way of listing partitions on a (win32) computer without
>>using WMI?
>>
> Maybe this will work (I skipped A: and B:, but you can include them if
> you want to catch floppy drives with something in them). The 'xxx' is just so 
> as
> not to get a full directory's worth of useless text. If xxx happens to be 
> defined
> it doesn't hurt anything. It's not going to be as fast as using one of the
> win32 api packages to get at GetLogicalDriveStrings, but this works on my NT4:
> (error messages apparently go to stderr, so stdout gets '' which makes the if 
> fail)
>
> >>> def fakeGetLogicalDriveStrings():
> ...     return [c+':' for c in (chr(n) for n in xrange(ord('A'), ord('Z')+1))
> ...                   if os.popen('dir %s:\\xxx'%c).read()]
> ...
> >>> fakeGetLogicalDriveStrings()
> ['C:', 'D:', 'E:', 'V:', 'W:']
>
> Regards,
> Bengt Richter

This will miss any partitions that don't have a drive letter assigned.
It will also give duplicate results for any volumes that have more
than one drive letter.  And it will return an entry for CD or DVD
drives which aren't disk partitions.

        Roger



----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet 
News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ 
Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to