Shortcuts and Variations for MCI Commands

The MCI string interface lets you use several shortcuts when working with MCI devices.

Using All as a Device Name

You can specify all as a device_name for any command that does not return information. When you specify all, MCI sequentially sends the command to all devices opened by the current application. For example, “close all” closes all open devices and “play all” starts playing all devices opened by the task. Because MCI sequentially sends the commands to the MCI devices, there is a delay between when the first device receives the command and when the last device receives the command.

Combining the Device Type and Device Element Name

You can eliminate the type flag in the open command if you combine the device type with the device element name. MCI recognizes this combination when you use the following syntax:

device_type ! element_name

The exclamation mark separates the device type from the element name. The following example opens the right.wav element with the waveaudio device:

 open waveaudio ! right.wav

Automatic Open

If MCI cannot identify the device_name of a command as an open device, MCI tries to automatically open the specified device. The following items apply to devices automatically opened:

Automatic open works only with the command-string interface.

Automatic open does not let your application specify the type flag. Without the device type, MCI determines the device type from the [mci extensions] section of the WIN.INI file. If you want to use a specific device, you can combine the device type name with the device element name using the exclamation mark.

Automatic open will fail for commands that are specific to custom device drivers. For example, the command to unlock the front panel of the Pioneer videodisc player will fail an automatic open. The command for unlocking the front panel is specific only to this videodisc player.

A device automatically opened will not respond to a command that uses all as a device name.

Automatic Close

MCI automatically closes any device automatically opened using the command-string interface. MCI closes a device when the command completes, when you abort the command, when you request notification in a subsequent command, or when MCI detects a failure.