// ntddstor.h
// CTL_CODE(0x002d, 0x201, METHOD_BUFFERED, FILE_READ_ACCESS)
#define IOCTL_STORAGE_MEDIA_REMOVAL 0x002D4804
View the official Windows Driver Kit DDI reference// winioctl.h
// CTL_CODE(0x002d, 0x201, METHOD_BUFFERED, FILE_READ_ACCESS)
#define IOCTL_STORAGE_MEDIA_REMOVAL 0x002D4804
View the official Win32 API referenceNo description available.
Locks the device to prevent removal of the media. If the driver can prevent the media from being removed while the drive is in use, it disables or enables the mechanism that ejects media on a device - the caller has opened for read or write access.
Unlike IOCTL_STORAGE_EJECTION_CONTROL, for which the driver tracks requests by caller, the driver ignores IOCTL_STORAGE_MEDIA_REMOVAL unlock requests only if its lock count is already zero, thereby allowing any caller to unlock the drive.
A driver for such a removable-media device that can support this IOCTL must do the following:
The buffer at Irp->AssociatedIrp.SystemBuffer contains a Boolean value, with TRUE indicating that the driver should lock the media in the drive.
The length of a Boolean.
None.
None.
The Information field is set to zero. The Status field is set to STATUS_SUCCESS, or possibly to STATUS_INVALID_DEVICE_REQUEST, STATUS_NO_MEDIA_IN_DEVICE, or STATUS_DEVICE_NOT_CONNECTED.
IOCTL_STORAGE_EJECTION_CONTROL
Enables or disables the mechanism that ejects media, for those devices possessing that locking capability.
To perform this operation, call the DeviceIoControl function with the following parameters.
BOOL DeviceIoControl(
(HANDLE) hDevice, // handle to device
IOCTL_STORAGE_MEDIA_REMOVAL, // dwIoControlCode
(LPVOID) lpInBuffer, // input buffer
(DWORD) nInBufferSize, // size of input buffer
NULL, // lpOutBuffer
0, // nOutBufferSize
(LPDWORD) lpBytesReturned, // number of bytes returned
(LPOVERLAPPED) lpOverlapped // OVERLAPPED structure
);
Irp->IoStatus.Status is set to STATUS_SUCCESS if the request is successful.
Otherwise, Status to the appropriate error condition as a NTSTATUS code.
For more information, see NTSTATUS Values.
The IOCTL_STORAGE_MEDIA_REMOVAL control code is valid only for devices that support removable media.