Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

How to disable media change notification messages on a class device timer


View products that this article applies to.

Symptoms

When a media changer moves media between storage and usage locations, the media changer incorrectly receives one media change notification message per second on a Microsoft Windows Server 2003-based computer or on a Microsoft Windows XP-based computer.

↑ Back to the top


Cause

This issue occurs because, by default, the media change notification functionality is enabled in both Windows Server 2003 and Windows XP.

↑ Back to the top


Resolution

To resolve this issue, disable the media change notification messages. To do this, call the DeviceIOControl function by using 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
);

Parameters

hDevice

[in] A handle to the device. Autoplay must be enabled on this device. To obtain a device handle, call the CreateFile function. Files must be opened with the FILE_READ_ATTRIBUTES access right. They must not be opened with read or with write access.
dwIoControlCode

[in] A control code for the operation. Use IOCTL_STORAGE_MCN_CONTROL for this operation.
lpInBuffer

[in] A pointer to a Boolean value. If this value is TRUE, media change detection is disabled. Otherwise, media change detection is enabled.
nInBufferSize

[in] The size of the input buffer, in bytes.
lpOutBuffer

A parameter that is not used with this operation; set to NULL.
nOutBufferSize

A parameter that is not used with this operation; set to 0 (zero).
lpBytesReturned

[out] The pointer to a variable that receives the size of the data that is stored in the output buffer, in bytes.

If the lpOverlapped parameter is NULL, the lpBytesReturned parameter cannot be NULL. Even when an operation returns no output data and the lpOutBuffer parameter is NULL, the DeviceIoControl function uses the lpBytesReturned parameter. In this scenario, the value of the lpBytesReturned parameter is meaningless.

If the lpOverlapped parameter is not NULL, the lpBytesReturned parameter may be NULL. If this parameter is not NULL and the operation returns data, the lpBytesReturned parameter is meaningless until the overlapped operation is completed. To retrieve the number of bytes that are returned, call the GetOverlappedResult method. If the hDevice handle is associated with an I/O completion port, you can retrieve the number of bytes that are returned by calling the GetQueuedCompletionStatus function.
lpOverlapped

[in] A pointer to an OVERLAPPED structure.

If the hDevice parameter was opened without specifying FILE_FLAG_OVERLAPPED, the lpOverlapped parameter is ignored.

If the hDevice parameter was opened by using the FILE_FLAG_OVERLAPPED flag, the operation is performed as an overlapped (asynchronous) operation. In this case, the lpOverlapped parameter must point to a valid OVERLAPPED structure that contains a handle to an event object. Otherwise, the function fails in unpredictable ways.

For overlapped operations, the DeviceIoControl function returns immediately, and the event object is signaled when the operation is completed. Otherwise, the function does not return until the operation is completed or until an error occurs.

Note If the operation is successful, the DeviceIoControl function returns a nonzero value. If the operation is not successful, the DeviceIoControl function returns 0 (zero). To obtain extended error information, call the GetLastError function.
Note The "[in]" reference at the beginning of some of these parameter explanations indicates an input parameter: The caller must provide the data. The "[out]" reference indicates an output parameter: The caller receives the data when the call is returned.

↑ Back to the top


References

For more information, visit the following Microsoft Web site:

↑ Back to the top


Keywords: KB831734, kbinfo, kbmm, kbwinservsetup

↑ Back to the top

Article Info
Article ID : 831734
Revision : 5
Created on : 2/1/2007
Published on : 2/1/2007
Exists online : False
Views : 278