IWMEncAudienceObj::put_Selected
The put_Selected method specifies a Boolean value indicating whether the current audience will be saved with the profile.
Syntax
HRESULT put_Selected(
VARIANT_BOOL fSelected
);
Parameters
fSelected
[in] VARIANT_BOOL that indicates whether the current audience is selected.
Return Values
If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.
Remarks
Using the IWMEncProfile2::SaveToFile, IWMEncProfile2::SaveToIWMProfile, or IWMEncProfile2::SaveToMemory method saves selected audiences along with the profile. Set the put_Selected method to VARIANT_FALSE for those audiences you do not want saved.
Example Code
// Include libraries.
#include <windows.h>
#include <atlbase.h>
#include <comdef.h>
#include "C:\WMSDK\WMEncSDK9\include\wmencode.h"
// Declare variables.
HRESULT hr;
IWMEncoder* pEncoder;
IWMEncProfileCollection* pProColl;
IWMEncProfile* pPro;
IWMEncProfile2* pPro2;
IWMEncAudienceObj* pAudnc;
// 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_IWMEncoder,
(void**) &pEncoder);
}
// Retrieve a specific profile.
if ( SUCCEEDED( hr ) )
{
hr = pEncoder->get_ProfileCollection(&pProColl);
}
if ( SUCCEEDED( hr ) )
{
hr = pProColl->Item(11, &pPro);
}
if ( SUCCEEDED( hr ) )
{
hr = CoCreateInstance(CLSID_WMEncProfile2,
NULL,
CLSCTX_INPROC_SERVER,
IID_IWMEncProfile2,
(void**) &pPro2);
}
if ( SUCCEEDED( hr ) )
{
hr = pPro2->LoadFromIWMProfile(pPro);
}
// Retrieve the first audience in the profile.
if ( SUCCEEDED( hr ) )
{
hr = pPro2->get_Audience(0, &pAudnc);
}
// Specify a value indicating whether the current audience is selected.
VARIANT_BOOL bSelected = VARIANT_FALSE;
if ( SUCCEEDED( hr ) )
{
hr = pAudnc->put_Selected(bSelected);
}
// Release pointers.
if ( pAudnc )
{
pAudnc->Release();
pAudnc = NULL;
}
if ( pPro2 )
{
pPro2->Release();
pPro2 = NULL;
}
Requirements
Header: wmencode.h
Library: wmenc.exe
See Also