// ntddstor.h
// CTL_CODE(0x002d, 0x251, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_STORAGE_MCN_CONTROL 0x002D0944
View the official Windows Driver Kit DDI reference// winioctl.h
// CTL_CODE(0x002d, 0x251, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_STORAGE_MCN_CONTROL 0x002D0944
View the official Win32 API referenceNo description available.
Temporarily enables or disables delivery of the custom PnP events GUID_IO_MEDIA_ARRIVAL and GUID_IO_MEDIA_REMOVAL on a removable-media device. This, in turn, enables or disables media change detection (AutoPlay) for the device if the caller has opened the device with FILE_READ_ATTRIBUTES access and if the device has AutoPlay enabled in the registry. The caller must not open the device for read or write access or the IOCTL operation will fail. This IOCTL has no effect on the AutoPlay setting in the registry.
A driver for such a removable-media device must do the following:
When the IRP_MJ_DEVICE_CONTROL IRP that contains this IOCTL is passed to the SCSI class driver, the FileObject member of the current IO_STACK_LOCATION must point to a valid file object. The SCSI class driver requires a file object for cases where a user-mode application that is disabling or enabling AutoPlay terminates unexpectedly. In such cases, the SCSI class driver uses the file object to reenable media change detection. Because the file object is necessary for proper clean-up, the SCSI class driver will cause the IRP to fail with an error message of STATUS_INVALID_PARAMETER if the FileObject member of IO_STACK_LOCATION does not point to a valid file object. If a user-mode application opens the device, then the I/O manager initializes this member, but kernel-mode driver writers should not assume that FileObject will be properly initialized when the IRP is generated by a user-mode application. If, for instance, a user-mode application mistakenly opens the device for either read or write access before sending the IOCTL, then the device control IRP will be routed through the file system, preventing the SCSI class driver and the device driver from directly accessing the device's file object.
The buffer at Irp->AssociatedIrp.SystemBuffer contains a Boolean value, with TRUE indicating that the driver should disable media change detection.
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_BUFFER_TOO_SMALL, STATUS_INVALID_PARAMETER, or STATUS_INVALID_DEVICE_STATE.
Enables or disables media change notification. Disabling media change notification prevents the GUID_IO_MEDIA_ARRIVAL and GUID_IO_MEDIA_REMOVAL events.
To perform this operation, call the DeviceIoControl function with the following parameters.
BOOL DeviceIoControl(
(HANDLE) hDevice, // handle to device
IOCTL_STORAGE_MCN_CONTROL, // 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.