The following code illustrates how to send a command to a specified device.

     CHAR szBuffer[128];                 /* String command buffer     */

     strcpy (szBuffer, "open bell.wav alias wav1 wait");
                                         /* String command to open     */

     mciSendString ((PSZ)szBuffer,       /* Open a wav file            */
                     NULL,               /* No return data             */
                     0,                  /* No return length           */
                     0,                  /* No window callback handle  */
                     0);                 /* No notify message          */

     strcpy (szBuffer, "play wav1 wait");/* String command to play     */

     mciSendString ((PSZ)szBuffer,       /* Play a wav file            */
                     NULL,               /* No return data             */
                     0,                  /* No return length           */
                     0,                  /* No window callback handle  */
                     0);                 /* No notify message          */

     strcpy (szBuffer, "close wav1 wait");/* String command to close   */

     mciSendString ((PSZ)szBuffer,       /* Close a wav file           */
                     NULL,               /* No return data             */
                     0,                  /* No return length           */
                     0,                  /* No window callback handle  */
                     0);                 /* No notify message          */


[Back] [Next]