Share via


Using Windows Media Device Manager from an Application

banner art

Applications instantiate Windows Media Device Manager to get information about service providers and transfer digital media content. The COM method CoCreateInstance can instantiate Windows Media Device Manager and provide any supported interface, but an application must be authenticated before the methods can be used. Therefore, request the IComponentAuthenticate interface when calling CoCreateInstance as shown in To Use IComponentAuthenticate with an Application. After Windows Media Device Manager has been instantiated and authenticated, QueryInterface is used to obtain the IWMDeviceManager interface. Methods on this interface supply information about the version of Windows Media Device Manager and get a count of portable devices connected to the host computer.

The authentication code for this section is found in Instantiating Windows Media Device Manager.

// CoCreateInstance()and authentication code precede the following code.
HRESULT hr;
IWMDeviceManager* pIdvMgr;
DWORD dwRevision;
DWORD dwCount;

hr = pIComponentAuthenticate->QueryInterface(IID_IWMDeviceManager, (void**)&pIdvMgr);
if SUCCEEDED(hr)
{
    wprintf(L"Got IWMDeviceManager\n");
    hr = pIdvMgr->GetRevision(&dwRevision);
    if SUCCEEDED(hr)
        wprintf(L"Revision = %d\n", dwRevision);
    hr = pIdvMgr->GetDeviceCount(&dwCount);
    if SUCCEEDED(hr)
        wprintf(L"Device Count = %d\n", dwCount);
}

See Also