How to determine if a CD is in CD-ROM drive

I was wondering if there is a Windows API that can tell me if there is a empty CD is inside a CD-ROM/DVD-Rom drive.

I've already looked at GetVolumeInformation(), but that only brings back information on the actual CD-ROM drive, not the media that is inside it, if there's even a CD in it or not.

All I'm trying to do is see if there's a cd in the drive or not and return a boolean value.

Thanks for any help


Call GetFileAttributes() on the root directory. GetFileAttributes() is quite optimized as it's commonly used as a check whether a file or directory exists.

Another method is to call GetDiskFreeSpace, which (despite its name) also returns the total disk size.

The Shell also has some useful functions. SHGetDriveMedia will tell you what's loaded, but you should first call GetDriveType().


The API you're looking for is most probably IMAPI.

I think this article here could be of help for you http://msdn.microsoft.com/en-us/magazine/cc163992.aspx