The following code illustrates how to send a command to a specified device.
MCI_OPEN_PARMS mciOpenParameters; MCI_PLAY_PARMS mciPlayParameters; CHAR DeviceType[] = "cdaudio"; /* Device type "cdaudio" */ mciPlayParameters.hwndCallback = PM_Win_Handle; /* Assign hwndCallback the handle to the PM Window routine */ mciOpenParameters.pszDeviceType = (PSZ)&DeviceType; mciSendCommand( 0, /* Don't know the device yet */ MCI_OPEN, /* MCI message */ MCI_WAIT | MCI_OPEN_TYPE_ID, /* Flags for the MCI message */ (PVOID) &mciOpenParameters, /* Parameters for the message */ 0 ); /* No notify message */ mciSendCommand( mciOpenParameters.usDeviceID, /* Device to play the cdaudio */ MCI_PLAY, /* MCI message */ MCI_WAIT, /* Flags for the MCI message */ (PVOID) &mciPlayParameters, /* Parameters for the message */ 0); /* No notify message */ mciSendCommand( mciOpenParameters.usDeviceID, /* Device to play the cdaudio */ MCI_CLOSE, /* MCI message */ MCI_WAIT, /* Flags for the MCI message */ (PVOID) NULL, /* No Parameter list */ 0); /* No notify message */