Share via


Create and Enable a Profile

The following code example illustrates how to create the Profile object and enable the profile for use by the RTC Client API. The operations in the Initialize RTC code example must be performed before using this example.

Note  This example does not contain error checking or releases appropriate for real code.

C++ Code Example

IRTCClientProvisioning *pIRTCClientProvisioning = NULL;
IRTCProfile            *pIRTCProfile            = NULL;
BSTR bstrXMLProfile     =  // XML Blob referenced in different section

// Perform QI for the Provisioning interface.
hr = pIRTCClient->QueryInterface(IID_IRTCClientProvisioning,
                  reinterpret_cast<void **>(&pIRTCClientProvisioning);

// If (hr != S_OK), process the error here. 

// Create the Profile object.
hr = pIRTCClientProvisioning->CreateProfile( bstrXMLProfile,
                                             &pIRTCProfile );

// If (hr != S_OK), process the error here. 

// Enable the Profile and Register. 
hr = pIRTCClientProvisioning->EnableProfile( pIRTCProfile, 
                                             RTCRF_REGISTER_ALL);

// If (hr != S_OK), process the error here. 

Visual Basic Code Example

'Set error handling routine here. 
' On Error GoTo MyErrorRoutine 

'Declare the Provisioning and Profile objects.
Private g_objProvisioning As IRTCClientProvisioning
Private g_objProfile As IRTCProfile

'Get the Provisioning object from the RTC Client object.
Set g_objProvisioning = g_objRTCClient

'Create the Profile object by providing the XML profile as a string.
Set g_objProfile = g_objProvisioning.CreateProfile(strXMLProfile)

'Enable the profile and register.
Call g_objProvisioning.EnableProfile(g_objProfile, RTCRF_REGISTER_ALL)