The following example closes all of the MCI devices that are opened by an application.
UINT wDeviceID;
DWORD dwReturn;
// Closes all MCI devices opened by this application.
// Waits until devices are closed before returning.
if(dwReturn = mciSendCommand(MCI_ALL_DEVICE_ID, MCI_CLOSE, MCI_WAIT,
NULL))
// Error, unable to close all devices.