MCI command messages consist of the following three elements:
A constant message value.
A parameter block specifying additional parameters for the command.
A set of flags specifying options for the command and validating fields in the parameter block.
Commands are sent with the mciSendCommand function which has parameters for the message, flags, and a pointer to the parameter block. See “Sending Command Messages,” later in this chapter, for more information about the mciSendCommand function.
For an example of an MCI command message, consider the MCI_PLAY command. The MMSYSTEM.H header file defines the MCI_PLAY command message, the MCI_PLAY_PARMS parameter block, and related flags as follows:
#define MCI_PLAY 0x0806
typedef struct {
DWORD dwCallback;
DWORD dwFrom;
DWORD dwTo;
} MCI_PLAY_PARMS;
#define MCI_NOTIFY 0x00000001L
#define MCI_WAIT 0x00000002L
#define MCI_FROM 0x00000004L
#define MCI_TO 0x00000008L
The MCI_WAIT and MCI_NOTIFY flags are option flags. MCI_WAIT tells the driver to wait until the command is complete before returning control to the application. MCI_NOTIFY tells the driver to notify the application when the command is complete. For more information on using these flags, see “Using the Wait and Notify Flags,” later in this chapter.
The MCI_FROM and MCI_TO flags validate the dwFrom and dwTo fields in the MCI_PLAY_PARMS parameter block. These fields specify beginning and ending positions for the play operation. Both of these flags are optional. If either flag is specified, the driver takes the value from the corresponding field in the parameter block as a beginning or ending position, otherwise the fields are ignored.
Note:
Data fields in a parameter block are ignored unless corresponding flags are specified to validate the fields.
Two commands that query devices for information, MCI_GETDEVCAPS and MCI_STATUS, extend the command-message paradigm by using item constants. Item constants specify which item of information is being queried for.
These commands extend the command-message paradigm by adding a dwItem field to the parameter block and defining item constants for the field. For example, MMSYSTEM.H defines the MCI_STATUS_PARMS parameter block, flags, and item constants as follows:
typedef struct {
DWORD dwCallback;
DWORD dwReturn;
DWORD dwItem;
DWORD dwTrack;
} MCI_STATUS_PARMS;
/* item consts for dwFlags param of MCI_STATUS command message */
#define MCI_STATUS_ITEM 0x00000100L
/* flags for dwItem field of MCI_STATUS_PARMS parameter block */
#define MCI_STATUS_LENGTH 0x00000001L
#define MCI_STATUS_POSITION 0x00000002L
#define MCI_STATUS_NUMBER_OF_TRACKS 0x00000003L
#define MCI_STATUS_MODE 0x00000004L
#define MCI_STATUS_MEDIA_PRESENT 0x00000005L
#define MCI_STATUS_TIME_FORMAT 0x00000006L
#define MCI_STATUS_READY 0x00000007L
#define MCI_STATUS_CURRENT_TRACK 0x00000008L
The MCI_STATUS_ITEM flag must be specified to validate the dwItem field which should contain one of the defined item constants to indicate exactly what status information is being requested.