IWMDRMContentAuthor::get_DRMProfileCollection

Windows Media Encoder SDK banner art

The get_DRMProfileCollection method retrieves an IWMDRMProfileCollection interface, which contains the collection of DRM profiles.

Syntax

HRESULT get_DRMProfileCollection(
  IWMDRMProfileCollection**  ppUnkDRMProfiles
);

Parameters

ppUnkDRMProfiles

[out]  Pointer to a pointer to an IWMDRMProfileCollection interface, which contains the collection of DRM profiles.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code Number Description
E_POINTER 0x80004003 The indirect pointer to the DRM profile collection is NULL.

Remarks

The IWMDRMProfileCollection interface enumerates all of the DRM profiles that are available to an encoding session. Only those DRM profiles that were created by the current user are available.

Example Code

// Include libraries.
#include <windows.h>
#include <atlbase.h>
#include <comdef.h>
#include "C:\WMSDK\WMEncSDK9\include\wmencode.h"
#include "C:\WMSDK\WMEncSDK9\include\wmdrmprf.h" // for DRM features

    HRESULT hr;
    IWMEncoder2* pEncoder;
    IWMDRMContentAuthor* pDRM;
    IWMDRMProfileCollection* pDRMProColl;
    IWMDRMProfile* pDRMPro;
    IWMDRMAttributes* pProAttr;

    // Initialize the COM library and retrieve a pointer
    // to an IWMEncoder interface.
    hr = CoInitialize(NULL);

    if ( SUCCEEDED( hr ) )
    {
        hr = CoCreateInstance(CLSID_WMEncoder,
            NULL,
            CLSCTX_INPROC_SERVER,
            IID_IWMEncoder2,
            (void**) &pEncoder);
    }

    // Create an IWMDRMContentAuthor object.
    if ( SUCCEEDED( hr ) )
    {
        hr = pEncoder->get_EncoderDRMContentAuthor(&pDRM);
    }

    // Retrieve the collection of DRM profiles.
    if ( SUCCEEDED( hr ) )
    {
        hr = pDRM->get_DRMProfileCollection(&pDRMProColl);
    }

    // Declare variables. Specify the provider's Web site and signature values.
    // The other variables are returned.
    CComBSTR sPublicKey;
    CComBSTR sWebURL("https://YourWebSite");
    CComVariant vProfileID;
    CComVariant vSeed;
    CComBSTR sSigPrivKey("Replace with signature private key");
    CComBSTR sSignedPubKey("Replace with signed public key");
    CComBSTR sSigLSCert("Replace with the licensor certificate");
    CComBSTR sSigRootCert("Replace with the Microsoft DRM License Server Root certificate");

    // Create the DRM profile. The public key, DRM profile ID, and
    // license key seed are returned.
    if ( SUCCEEDED( hr ) )
    {
        hr = pDRM->CreateDRMProfile(sWebURL, sSigPrivKey, sSignedPubKey, sSigLSCert, sSigRootCert, &vProfileID, &vSeed, &sPublicKey);
    }

    // Create an IWMDRMProfile object and retrieve a profile.
    CComVariant vIndex(0);
    if ( SUCCEEDED( hr ) )
    {
        hr = pDRMProColl->Item(vIndex, &pDRMPro);
    }

    // Set the rest of the properties for the DRM profile.
    if ( SUCCEEDED( hr ) )
    {
        hr = pDRMPro->put_Description(CComBSTR("Replace with a description of this DRM profile"));
    }
    if ( SUCCEEDED( hr ) )
    {
        hr = pDRMPro->put_LicenseAcquisitionURL(CComBSTR("Replace with v7 license acquisition URL"));
    }
    if ( SUCCEEDED( hr ) )
    {
        hr = pDRMPro->put_Name(CComBSTR("Replace with a name for the DRM profile"));
    }
    if ( SUCCEEDED( hr ) )
    {
        hr = pDRMPro->put_V1LicenseAcquisitionURL(CComBSTR("Replace with v1 license acquisition URL"));
    }

    // Add the individualization version as an attribute.
    // This attribute should be saved in the DRM profile. 
    if ( SUCCEEDED( hr ) )
    {
        hr = pDRMPro->get_Attributes(&pProAttr);
    }
    if ( SUCCEEDED( hr ) )
    {
        hr = pProAttr->Add(CComBSTR("SECURITYVERSION"), CComVariant("2.2"));
    }

    // Add the content ID as an attribute. This attribute is for the current
    // session only and is not saved in the profile.
    if ( SUCCEEDED( hr ) )
    {
        hr = pDRM->get_Attributes(&pProAttr);
    }
    if ( SUCCEEDED( hr ) )
    {
        hr = pProAttr->Add(CComBSTR("ContentID"), CComVariant("10011"));
    }

    // Set the profile into the DRM session.
    CComVariant vKeyID;
    CComBSTR sProID;
    if ( SUCCEEDED( hr ) )
    {
        hr = pDRMPro->get_ID(&sProID);
    }
    if ( SUCCEEDED( hr ) )
    {
        hr = pDRM->SetSessionDRMProfile(sProID, &vKeyID);
    }

    // Release pointers.
    if ( pDRM )
    {
        pDRM->Release();
        pDRM = NULL;
    }
    if ( pDRMProColl )
    {
        pDRMProColl->Release();
        pDRMProColl = NULL;
    }
    if ( pDRMPro )
    {
        pDRMPro->Release();
        pDRMPro = NULL;
    }
    if ( pProAttr )
    {
        pProAttr->Release();
        pProAttr = NULL;
    }
    if ( pEncoder )
    {
        pEncoder->Release();
        pEncoder = NULL;
    }

Requirements

Header: wmdrmprf.h

Library: wmenc.exe

See Also