Share via


Windows Media Player 11 SDK Retrieving the Ripping Interface 

Windows Media Player SDK banner art

Previous Next

Retrieving the Ripping Interface

To enumerate the CD drives on the user's computer, use the IWMPCdromCollection interface. 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 for each CD drive on the user's computer.

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

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

HRESULT CMainDlg::GetCdromDriveCount (long &lDriveCount)
{
    HRESULT 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::GetCdromRipInterface (long lIndex)
{
    // Get the IWMPCdrom interface.
    m_spCdrom.Release();
    HRESULT hr = m_spCdromCollection->item(lIndex, &m_spCdrom);
    if (SUCCEEDED(hr))
    {
        // Get the IWMPCdromRip interface.
        m_spCdromRip.Release();
        hr = m_spCdrom->QueryInterface(&m_spCdromRip);
    }

    return hr;
}

See Also

Previous Next