Share via


IWMDMStorageGlobals::GetSerialNumber

banner art

The GetSerialNumber method retrieves a serial number that uniquely identifies the storage medium.

Syntax

HRESULT GetSerialNumber(PWMDMIDpSerialNum,BYTE[WMDM_MAC_LENGTH]abMac);

Parameters

pSerialNum

[out]  Pointer to a WMDMID structure specifying the serial number information.

abMac

[in, out]  Array of bytes specifying the message authentication code for the parameter data of this method. This memory is allocated and freed by the caller.

Return Values

The method returns an HRESULT. All the interface methods in Windows Media Device Manager can return any of the following classes of error codes:

  • Standard COM error codes
  • Windows error codes converted to HRESULT values
  • Windows Media Device Manager error codes

For an extenstive list of possible error codes, see Error Codes.

Possible values include, but are not limited to, those in the following table.

Return code Description
E_INVALIDARG The pSerialNum parameter is an invalid or NULL pointer.
WMDM_E_NOTSUPPORTED The device does not support serial numbers.
E_FAIL An unspecified error occurred.
WMDM_E_NOTCERTIFIED The caller is not certified.
WMDM_E_MAC_CHECK_FAILED The message authentication check failed.

Remarks

Not all storage media support serial numbers, but a serial number is required to support Microsoft digital rights management. If the storage medium cannot report a unique serial number, content protected by Microsoft digital rights management cannot be transferred to this storage medium. The return code should be checked to determine whether the storage medium provides this support.

Example Code

The following C++ code retrieves the serial number of the root storage object, and verifies the MAC.

    hr = m_pStorageGlobals->GetSerialNumber(&m_SerialNumber, (BYTE*)abMAC);
    if (SUCCEEDED(hr))
    {
        // Verify the MAC using the CSecureChannelClient member.
        m_pSAC->MACInit(&hMAC);
        m_pSAC->MACUpdate(hMAC, (BYTE*)(&m_SerialNumber), sizeof(m_SerialNumber));
        m_pSAC->MACFinal(hMAC, (BYTE*)abMACVerify);
        if (memcmp(abMACVerify, abMAC, sizeof(abMAC)) != 0)
        {
            hr = E_FAIL;
        }
    }

Requirements

Header: Defined in mswmdm.h.

Library: mssachlp.lib

See Also