Reputation: 42255
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?
Upvotes: 1
Views: 1597
Reputation: 116167
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).
Upvotes: 1
Reputation: 2558
As this page explains: http://msdn.microsoft.com/en-us/library/windows/desktop/bb776153%28v=vs.85%29.aspx
GetRecorderDriveLetter will return drive letter which is a burner (if exists) or it will return an error code if there is no drive which could burn a CD.
If you need more samples, just search the API
Upvotes: 1
Reputation: 37132
The drive index (0 = A, 1 = B, etc) for the Windows CD burner can be found in the registry at HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\CD Burning\DriveIndex.
Upvotes: 3