Closing All MCI Devices Used by an Application
[The feature associated with this page, MCI, is a legacy feature. It has been superseded by MediaPlayer. MediaPlayer has been optimized for Windows 10 and Windows 11. Microsoft strongly recommends that new code use MediaPlayer instead of MCI, when possible. Microsoft suggests that existing code that uses the legacy APIs be rewritten to use the new APIs if possible.]
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,
NULL))
// Error, unable to close all devices.