检索 CD 刻录接口

[与此页面关联的功能(Windows 媒体播放器 SDK)是旧版功能。 它已被 MediaPlayer 取代。 MediaPlayer 已针对Windows 10和Windows 11进行了优化。 Microsoft 强烈建议新代码尽可能使用 MediaPlayer 而不是 Windows 媒体播放器 SDK。 如果可能,Microsoft 建议重写使用旧 API 的现有代码以使用新 API。]

若要枚举用户计算机上的 CD 驱动器,请使用 IWMPCdromCollection 接口。 通过调用 IWMPCore::get_cdromCollection 检索指向此接口的指针。

通过使用 get_count 方法,可以循环访问集合以检索用户计算机上的每个 CD 驱动器的 IWMPCdrom 接口指针。

IWMPCdrom 接口表示单个 CD 驱动器。 在开始燃烧 CD 之前,必须先通过 IWMPCdrom 指针调用 QueryInterface,以检索指向 IWMPCdromBurn 接口的指针。

以下代码示例演示如何检索用于将 CD 烧录到特定驱动器的接口:

HRESULT CMainDlg::GetCdromDriveCount (long &lDriveCount)
{
    hr = m_spPlayer->get_cdromCollection(&m_spCdromCollection);

    // Get the number of CDROM drives.
    if (SUCCEEDED(hr))
    {
        hr = m_spCdromCollection->get_count(&lDriveCount);
    }

    return hr;
}

// lIndex refers to the index of the current drive,
// which must be less than the value retrieved by
// GetCdromDriveCount above.
HRESULT CMainDlg::GetCdromBurnInterface (long lIndex)
{
    // Get the IWMPCdrom interface.
    m_spCdrom.Release();
    HRESULT hr = m_spCdromCollection->item(lIndex, &m_spCdrom);
    if (SUCCEEDED(hr))
    {
        // Get the IWMPCdromBurn interface.
        m_spCdromBurn.Release();
        hr = m_spCdrom->QueryInterface(&m_spCdromBurn);
    }

    return hr;
}

刻录 CD

启动燃烧过程

擦除可重写的 CD

检索驱动器和光盘状态

检索燃烧状态

IWMPCdromCollection 接口