The Wait, Notify, and Test Flags

Most MCI commands include flags that modify the command. The “wait” (MCI_WAIT) and “notify” (MCI_NOTIFY) flags are common to every command. The “test” (MCI_TEST) flag is available to digital-video and VCR devices. This section describes the use of these flags.

The Wait Flag

MCI commands usually return to the user immediately, even if it takes several minutes to complete the action initiated by the command. You can use the “wait” (MCI_WAIT) flag to direct the device to wait until the requested action is completed before returning control to the application.

For example, the following play command will not return control to the application until the playback completes:

play mydevice from 0 to 100 wait

Note The user can cancel a wait operation by pressing a break key. By default, this key is CTRL+BREAK. Applications can redefine this key by using the break command. When a wait operation is canceled, MCI attempts to return control to the application without interrupting the command associated with the “wait” flag.

The Notify Flag

The “notify” (MCI_NOTIFY) flag directs the device to post an MM_MCINOTIFY message when the device completes an action. Your application must have a window procedure to process the MM_MCINOTIFY message for notification to have any effect. An MM_MCINOTIFY message indicates that the processing of a command has completed, but it does not indicate whether the command was completed successfully, failed, or was superseded or aborted.

The application specifies the handle to the destination window for the message when it issues a command. In the command-string interface, this handle is the last parameter of the function.

The Test Flag

The “test” (MCI_TEST) flag queries the device to determine if it can execute the command. The device returns an error if it cannot execute the command. It returns no error if it can handle the command. When you specify this flag, MCI returns control to the application without executing the command.

This flag is supported by digital-video and VCR devices for all commands except open and close.