Share via


Windows Media Player 11 SDK Retrieving the CD Burning Interface 

Windows Media Player SDK banner art

Previous Next

Retrieving the CD Burning Interface

To enumerate the CD drives on the user's computer, use the IWMPCdromCollection interface. You retrieve a pointer to this interface by calling IWMPCore::get_cdromCollection.

By using the get_count and item methods, you can iterate the collection to retrieve an IWMPCdrom interface pointer for each CD drive on the user's computer.

The IWMPCdrom interface represents an individual CD drive. Before you begin burning a CD, you must first call QueryInterface through an IWMPCdrom pointer to retrieve a pointer to the IWMPCdromBurn interface.

The following code example demonstrates how to retrieve an interface for burning a CD to a specific drive:

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;
}

See Also

Previous Next