Closing All MCI Devices Used by an Application

The following example closes all of the MCI devices that are opened by an application using the mciSendCommand function.

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, 
    // Error, unable to close all devices.