CD Insert Notification in WinXP

Josiah Carlson jcarlson at
Wed Jan 21 02:30:00 CET 2004

> I'm using Python 2.3 on a Win XP box, and I'm trying to find if there's 
> a library of some sort that will give you a callback (or something 
> comparable) when a new disc is inserted into a CD Rom drive. I've done a 
> little googling and nothing's come up, so I'm not holding my breath. :)
> If not, I'm thinking of implementing a thread to periodically read the 
> volume serial number using GetVolumeInformation from Mark Hammond's Win 
> 32 extensions, then doing a compare against the last known value. Does 
> this sound "sane"? Any recommendations would be useful.


Generally, Windows autoinsert notification can be enabled or disabled
for data and audio disks independantly.  When autoinsert notification is
enabled on data disks, the Windows operating system automatically does
what CD:\autorun.inf says.

I would imagine that a similar thing occurs on audio cd inserts, except
that it automatically calls the program that is associated with .cda

Certainly there are hooks into the OS that allow one to intercept
filesystem read/write calls (it is what virus scanners do), which could
be tested to see if the read is from a cdrom drive, but I don't know if
Mark Hammond's extensions would be enough, though it is doubtful.

I would suggest polling the serial number every 5 seconds or so, making
sure to deal with the various exception conditions.

 - Josiah

More information about the Python-list mailing list