Name/ID of removable Media: how?

Tim Golden tim.golden at viacom-outdoor.co.uk
Tue Apr 19 06:27:44 EDT 2005


[Heiko Selber]
| I am trying to find out (using Python under windows) the name 
| of a CD that
| is currently in the drive specified by a path name.
| 
| And while I am at it, I'd also like to know whether the 
| specified drive
| contains a CD at all, and whether the drive is actually a CD drive.

Try this:

<code>
import wmi

c = wmi.WMI ()
for i in c.Win32_CDROMDrive ():
  print i.Caption, i.VolumeName, i.VolumeSerialNumber

</code>

I haven't answered all your questions, but I'm willing
to bet that you can do pretty much what you want with
WMI.

There are also the pywin32 functions which give you some
of this (maybe all, don't know; haven't tried).

More info here: http://timgolden.me.uk/python/wmi.html
and here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/win32_cdromdrive.asp
and here: http://pywin32.sf.net

TJG

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________



More information about the Python-list mailing list