IWMSContext::SetStringValue

banner art

Previous Next

IWMSContext::SetStringValue

The SetStringValue method specifies a string value in the context.

Syntax

  HRESULT SetStringValue(
  LPCWSTR  pstrName,
  long  lNameHint,
  LPCWSTR  pstrValue,
  long  lOptions
);

Parameters

pstrName

[in] LPCWSTR specifying the name portion of the name-value pair in the context.

lNameHint

[in] long containing an optional key that can be used to more efficiently access a value.

qwValue

[in] LPCWSTR containing the value portion of the name-value pair.

lOptions

[in] long containing either zero or the WMS_CONTEXT_SET_PROPERTY_NAME_BY_VALUE enumeration flag defined in the WMS_CONTEXT_OPTIONS enumeration type. By default, the name is specified by reference.

Return Values

If the method succeeds, it returns S_OK. If it fails, it returns an HRESULT error code.

Return code Number Description
E_INVALIDARG 0x80070057 The pstrName parameter is NULL.
E_OUTOFMEMORY 0x8007000E Could not allocate memory for the value.

Example Code

// Use a pointer to an IWMSClassObject interface, pFactory,
// to create an empty content description list. The server sends 
// your plug-in a pointer to the IWMSClassObject interface when 
// it calls the IWMSBasicPlugin::InitializePlugin method.
if(NULL != pFactory)
{
    hr = pFactory->CreateInstance(
                        IID_IWMSContentDescriptionList,
                        (void **) &m_pContentDescriptionList );
    if (FAILED(hr)) goto EXIT;

    // Create a content description context. The return value,
    // pContentDescription, contains a pointer to the context.
    hr = pFactory->AllocIWMSContext(
                        IID_IWMSContext,
                        WMS_CONTENT_DESCRIPTION_CONTEXT_TYPE,
                        NULL,
                        (void **) &pContentDescription );
    if (FAILED(hr)) goto EXIT;

    // Add the title to the content description context.
    hr = pContentDescription->SetStringValue(
                        WMS_CONTENT_DESCRIPTION_TITLE,
                        WMS_CONTENT_DESCRIPTION_TITLE_ID,
                        L"Title",
                        0 );
    if (FAILED(hr)) goto EXIT;
}

// Use a pointer to the user context to insert the protocol 
// name. This demonstrates the use of the 
// WMS_CONTEXT_SET_PROPERTY_STRING_BY_REFERENCE enumeration
// value.
if(NULL ! pUserContext)
{
    hr = pUserContext->SetStringValue( 
                          WMS_USER_CONTROL_PROTOCOL, 
                          WMS_USER_CONTROL_PROTOCOL_ID, 
                          WMS_MMS_PROTOCOL_NAME, 
                          WMS_CONTEXT_SET_PROPERTY_STRING_BY_REFERENCE );
    if (FAILED(hr)) goto EXIT;
}

EXIT:
    // TODO: Release temporary objects.

Requirements

Header: wmscontext.h.

Library: WMSServerTypeLib.dll.

Platform: Windows Server 2003, Enterprise Edition; Windows Server 2003, Datacenter Edition; Windows Server 2008.

See Also

Previous Next