Command Strings

String commands utilize a more English text format than command messages. Following is the valid syntax for passing string commands directly to the media control interface:

<COMMAND> <DEVICE_TYPE|DEVICE_NAME|ALIAS|ELEMENT> <PARAMETERS>

This format is used for all string commands except masteraudio, which does not require a device name. The format for the masteraudio command is:

<COMMAND> <PARAMETERS>

An application calls mciSendString to pass the string command to the Media Device Manager for parsing and execution. The String Test Sample program, provided in the Toolkit (\TOOLKIT\SAMPLES\MM\MCISTRNG), illustrates the interpretive string interface. The following code fragment shows the call to mciSendString in the String Test Sample.

ulSendStringRC =
   mciSendString(
    (PSZ) &acMCIString[ 0 ],          /* The MCI String Command     */
    (PSZ) &acMCIReturnString[ 0 ],    /* Place for return strings   */
    (USHORT) MCI_RETURN_STRING_LENGTH, /* Length of return space     */
    hwndDisplayDialogBox,              /* Window to receive notifies */
    usCountOfMCIStringSent );          /* The user parameter         */

The following is an example of the string commands required to open a CD player and play an entire CD.

open cdaudio01 alias cdaud1 shareable
status cdaud1 media present wait
status cdaud1 mode wait
set cdaud1 time format milliseconds
seek cdaud1 to start
play cdaud1 notify
.
.
.
** play the entire disc **
.
.
.
close cdaud1

The status commands let the application know if a CD is present and if the drive is ready. Notice that wait flags are used; otherwise the commands would return immediately with no status information. The set command sets the time base to milliseconds for all future commands. The close command is sent after the application receives an MM_MCINOTIFY message at the completion of the play command.

Note: The close command can be sent at any time.