The MCI_NOTIFY flag directs the device driver to return immediately as usual and to post the MM_MCINOTIFY message when the requested action is complete. When the action is complete, use mciDriverNotify to notify the window function specified by the application.
Specify the handle to the window associated with the callback window function in the hCallback parameter of mciDriverNotify. You can obtain this handle from the low-order word of the dwCallBack member of the structure sent with the message. Specify the device ID in the uDeviceID parameter. Specify the status of the notification in the wStatus parameter. Four possibilities exist for the status:
Your device driver sends MCI_NOTIFY_SUCCESSFUL when it successfully completes the actions requested by the command with MCI_NOTIFY set.
Your device driver sends MCI_NOTIFY_SUPERSEDED when an application sends another MCI message with the MCI_NOTIFY flag before the conditions for the first notify are met. In this case, your device driver calls the pending callback function and resets the callback conditions to correspond to the new command requesting notification.
Your device driver sends MCI_NOTIFY_ABORTED when an application sends a command that prevents the callback conditions from being satisfied. For example, the stop command would abort a notification pending for the "play to 500 notify" command.
Your device driver sends MCI_NOTIFY_FAILURE when a hardware failure prevents the callback conditions from being satisfied. When your driver receives a command with MCI_NOTIFY, it should verify that it can successfully complete the command before it returns to the application. If your driver anticipates an error, it should fail and not return any notification status.
Your device driver will perform the following tasks for handling the MCI_NOTIFY flag:
A simple example of determining if the MCI_NOTIFY flag is set in lParam1 is shown in the following code fragment:
wStatus = MCI_NOTIFY_SUCCESSFUL;
if (lParam1 & MCI_NOTIFY)
mciDriverNotify (hCallBack, uDeviceID, wStatus);
This fragment checks for the MCI_NOTIFY flag and, if found, calls mciDriverNotify to send the status message to the application-specified window function. This fragment is appropriate if the time to complete the action requested of your driver is insignificant. For example, the time required to determine and return information requested by the MCI_INFO and MCI_GETDEVCAPS is the execution time of your device driver (that is, there are no processing or hardware delays). Because there is no delay, the fragment does not need a timer or interrupt to determine when the device completes the action.
Actions that have a noticeable delay associated with them require a more sophisticated approach to determine when the device finishes. One possible way your driver might achieve this is by setting a timer to periodically call a timer function that interrogates the status of the device. Once your device driver sets the timer and timer function, it can return control to the calling application. If your MCI device has the capability of generating hardware interrupts, your device driver might use these interrupts rather than the timer.