Name/ID of removable Media: how?

Heiko Selber heiko.selber at siemens.com
Tue Apr 19 09:44:14 EDT 2005


Aah, nice. Thank you.

This should be included in pywin32, don't you think so? (Or is it? I didn't
check before installing.)

Heiko

"Tim Golden" <tim.golden at viacom-outdoor.co.uk> wrote in message
news:mailman.2088.1113906469.1799.python-list at python.org...
[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





More information about the Python-list mailing list