關閉應用程式使用的所有 MCI 裝置

[與此頁面 MCI相關聯的功能是舊版功能。 MediaPlayer已取代它。 MediaPlayer已針對Windows 10和Windows 11進行優化。 Microsoft 強烈建議新程式碼盡可能使用 MediaPlayer 而非 MCI。 Microsoft 建議使用舊版 API 的現有程式碼盡可能重寫為使用新的 API。

下列範例會關閉應用程式使用 mciSendCommand 函式開啟的所有 MCI 裝置。

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.