Finding mountpoints in windows

Simon Brunning SBrunning at trisystems.co.uk
Tue Jan 15 11:39:48 EST 2002


> From:	Simon Brunning 
> 	From:	Stephen Boulet [SMTP:stephen.boulet at motorola.com]
> 	I see that I can use os.chdir to get from, say, N: to C:. Is there a
> way
> 	to list the mountpoints if I can't assume what they are beforehand?
>  
> You'll need win32all. Then you use:
> 
> import win32api, win32file
> 
> drives = [drive for drive in
> win32api.GetLogicalDriveStrings().split('\x00')[:-1] if
> win32file.GetDriveType(drive) == win32file.DRIVE_FIXED]
 
Woops! This will only get you the local hard drives. You'll need to look at
the win32file.DRIVE_whatever values to see which ones you want:

*	win32file.DRIVE_CDROM
*	win32file.DRIVE_FIXED
*	win32file.DRIVE_NO_ROOT_DIR
*	win32file.DRIVE_RAMDISK
*	win32file.DRIVE_REMOTE
*	win32file.DRIVE_REMOVABLE
*	win32file.DRIVE_UNKNOWN

So if you wanted to see *all* local drives, including CD-ROMs, floppies and
so on, for example, you'd use:

drives = [drive for drive in
win32api.GetLogicalDriveStrings().split('\x00')[:-1] if
win32file.GetDriveType(drive) in [win32file.DRIVE_FIXED,
win32file.DRIVE_CDROM, win32file.DRIVE_REMOVABLE]]

Enjoy.

Cheers,
Simon Brunning
TriSystems Ltd.
sbrunning at trisystems.co.uk





-----------------------------------------------------------------------
The information in this email is confidential and may be legally privileged.
It is intended solely for the addressee. Access to this email by anyone else
is unauthorised. If you are not the intended recipient, any disclosure,
copying, distribution, or any action taken or omitted to be taken in
reliance on it, is prohibited and may be unlawful. TriSystems Ltd. cannot
accept liability for statements made which are clearly the senders own.




More information about the Python-list mailing list