Windows' CD-ROM class driver includes support for an IOCTL_CDROM_EXCLUSIVE_ACCESS request. This request instructs the CD-ROM class driver to:
CD/DVD/BD recording applications use this IOCTL to ensure that they have exclusive access to the device while they are recording to it. This utility, included with busTRACE 10.0, provides a means for you to monitor which application has received exclusive access to the device. You can run this utility from the busTRACE Start Menu. Here is a sample screenshot: In this sample, we are using Windows to erase a CD-RW disc in our HL-DT-ST DVD recorder. Note how the application shows you that "Windows" currently has exclusive access to the device. When you select a CD/DVD/BD device, the toolbar buttons will become enabled. If you are a software developer, you can use these buttons to force a lock of the drive to see how your software handles a "locked" condition.
The following information is available in more detail within the Windows Driver Kit (WDK). We provide some basic information so that you can better understand what our application is doing. Report the access state of a CD-ROM deviceTo determine the current access state of a CD-ROM device, we issue an IOCTL_CDROM_EXCLUSIVE_ACCESS with a CDROM_EXCLUSIVE_ACCESS structure to the class driver. This structure is defined in the WDK as follows:
The EXCLUSIVE_ACCESS_REQUEST_TYPE-typed enumeration value is defined as:
We set the RequestType field to ExclusiveAccessQueryState and set the Flags field to zero. The CD-ROM class driver then returns to us a CDROM_EXCLUSIVE_LOCK_STATE structure. This structure is defined as:
The LockState field returns TRUE if the device is locked, else FALSE. If the device is locked, we can look at the returned CallerName field to determine who has received an exclusive lock on the device. Lock a CD-ROM device for exclusive accessTo gain exclusive access to a CD/DVD/BD device, we issue an IOCTL_CDROM_EXCLUSIVE_ACCESS with a CDROM_EXCLUSIVE_LOCK structure to the class driver. This structure is defined in the WDK as follows:
See above for a definition of the CDROM_EXCLUSIVE_ACCESS structure. To lock the device, we set the Access.RequestType field to ExclusiveAccessLockDevice. We set the Flags field to 0 to use with a dismounted file system or 1 to ignore the file system mount. We also set the CallerName field with an identifier string. Unlock a CD-ROM deviceTo release our exclusive lock on a CD/DVD/BD device, we issue an IOCTL_CDROM_EXCLUSIVE_ACCESS with a CDROM_EXCLUSIVE_LOCK structure to the class driver. See above for a definition. We set the Access.RequestType field to ExclusiveAccessUnlockDevice. Additional InformationFull information on IOCTL_CDROM_EXCLUSIVE_ACCESS can be found in Microsoft's Windows Driver Kit (WDK). Structure declarations can be found in the WDK file ntddcdrm.h. |
|