Share via


IWMDRMDeviceApp::QueryDeviceStatus

banner art

The QueryDeviceStatus method queries a device for its current DRM status and capabilities.

Syntax

HRESULT QueryDeviceStatus(IWMDMDevice*pDevice,DWORD*pdwStatus);

Parameters

pDevice

[in]  Pointer to an IWMDMDevice object.

pdwStatus

[out] Zero or more of the following DWORD values describing the DRM aspects of the device, combined with a bitwise OR. See Remarks.

Status Description
WMDRM_DEVICE_ISWMDRM The device supports Windows Media DRM.
WMDRM_DEVICE_NEEDCLOCK The device does not have a secure clock.
WMDRM_DEVICE_REVOKED The device has been revoked.
WMDRM_CLIENT_NEEDINDIV The DRM security needs to be individualized.
WMDRM_DEVICE_REFRESHCLOCK The clock needs to be refreshed.

Return Values

The method returns an HRESULT. Possible values include, but are not limited to, those in the following table.

Return code Description
S_OK The method succeeded.
DRM_E_INVALIDARG The input argument is not valid.
NS_E_DRM_INVALID_CERTIFICATE The device certificate retrieved from the device is not valid.
NS_E_DRM_UNABLE_TO_GET_DEVICE_CERT Failed to retrieve the device certificate from the device.

Remarks

This method should be called before performing any restricted actions on DRM content, such as transferring DRM content to the device, or acquiring metering information. If the values retrieved by pdwStatus indicate that some action needs to be performed (such as individualization for the desktop or acquiring a clock for the device), the application should call AcquireDeviceData and pass the retrieved pdwStatus value from this function to the dwFlags parameter in AcquireDeviceData. If zero is returned, the device does not support Windows Media DRM 10 for Portable Devices, and no actions need be taken. See Handling Protected Content in the Application for more information.

Example Code

The following C++ code example creates a WMDRMDeviceApp object, verifies that the device is a Windows Media DRM 10 device, that its clock is accurate, and then requests the metering data.

HRESULT hr = S_OK;
// Create the WMDRMDeviceApp object.
CComPtr<IWMDRMDeviceApp> pDRM;
hr = pDRM.CoCreateInstance(CLSID_WMDRMDeviceApp, 0, CLSCTX_ALL);

// Find out first if the device is a WMDRM 10 device, and if it requires
// any clock updates.
DWORD status = 0;
hr = pDRM->QueryDeviceStatus(pDevice, &status);

if (!(WMDRM_DEVICE_ISWMDRM & status)) // Device is not WMDRM 10. Nothing can be updated,
    return E_FAIL;                   // and metering cannot be performed.
else if (status & WMDRM_DEVICE_REVOKED) // Device is revoked.
    return E_FAIL;
else if (status & WMDRM_DEVICE_NEEDCLOCK || 
    status & WMDRM_CLIENT_NEEDINDIV ||
    status & WMDRM_DEVICE_REFRESHCLOCK)
{
    // Need to update device clock. 
    // Using custom function, which is synchronous.
    hr = myAcquireDeviceData(pDRM, pDevice, this, status, &result);
    if (hr != S_OK || result != 0)    // Couldn't perform the updates.
        return E_FAIL;    
}

Requirements

Header: Requires both WMDRMDeviceApp.h and wmdrmdeviceapp_i.c (built from WMDRMDeviceApp.idl).

Library: mssachlp.lib

See Also