IWMDRMProfile::get_ID
![]() |
The get_ID method retrieves the ID of the current DRM profile.
Syntax
HRESULT get_ID(
BSTR* pbstrProfileID
);
Parameters
pbstrProfileID
[out] Pointer to a BSTR containing the profile ID.
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 pointer to the profile ID is NULL. |
Remarks
It is recommended that you keep the DRM profile ID secure; for example, do not add this as an attribute to content headers.
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
.gif)