I want to block the user to backup files to optical discs, so I have to determine if a CDROM drive is writable.
How to do under Windows?
You can use method used by open-source CD/DVD recording application InfraRecorder (git repo).
InfraRecorder is using ckmmc library to get list of compatible devices using ckmmc::DeviceManager
class (it supports multiple devices, of course).
First it scans for all devices using ckmmc DeviceManager::scan()
, and then checks if device is a recorder using method MmcDevice::recorder()
.
You would think that there must be easier way to do this using something like GetDriveType()
or DeviceIoControl()
, but unfortunately it is not that simple.
ckmmc
supports two different device access methods: ASPI (Advanced SCSI Programming Interface) and SPTI (SCSI Pass-Through Interface). To get drive properties it actually sends SCSI commands to the device, and only then it can analyze SCSI mode page and tell which recording modes (CD-R, CD-RW, DVD-R, DVD+R, etc...) hardware supports (if any).