The following code illustrates how to stop an audio or video device during playback or recording, and receive notification upon completion.
USHORT usDeviceID;
HWND hwndMyWindow;
MCI_GENERIC_PARMS mciGenericParms; /* Info data structure
for command */
/* Assign hwndCallback the handle to the PM Window */
mciGenericParms.hwndCallback = hwndMyWindow;
/* Stop the device */
mciSendCommand( usDeviceID, /* Device ID */
MCI_STOP, /* MCI stop message */
MCI_NOTIFY, /* Flag for this message */
(PVOID) &mciGenericParms, /* Data structure */
0); /* No user parm */