Win32 Drive List Redux

Tim Daneliuk tundra at tundraware.com
Thu Jan 2 20:50:07 EST 2003


Tim Daneliuk wrote:
> Some time ago, there was a brief thread on how to get a list of
> available drives on Win32.  Peter Hansen suggested the use of:
<SNIP>

Well, here is a "Sort-Of" solution. It suffers from the fact that it is
not in sync with reality of the machine - it reports B: on my system
(which has none) and incorrectly shows a network drive that has been
detatched.  Still, its kind of interesting...


from _winreg import *

reg  = ConnectRegistry(None,HKEY_CURRENT_USER)
k = OpenKey(reg, r"Software\Microsoft\Windows\CurrentVersion\Explorer\MountPoints")

drivelist = []
for i in range(QueryInfoKey(k)[0]):
     drivelist.append(EnumKey(k,i) + ":\\")

CloseKey(k)
CloseKey(reg)
print drivelist




-- 
------------------------------------------------------------------------------
Tim Daneliuk
tundra at tundraware.com





More information about the Python-list mailing list