IWMSServer::get_MonikerName

banner art

Previous Next

IWMSServer::get_MonikerName

The get_MonikerName method retrieves the moniker display name that can be used to create and initialize a WMSServer object.

Syntax

  HRESULT get_MonikerName(
  BSTR*  pbstrVal
);

Parameters

pbstrVal

[out] Pointer to a BSTR representing the display name.

Return Values

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

Return code Number Description
E_OUTOFMEMORY 0x8007000E Indicates that there is insufficient memory to complete the function.
E_POINTER 0x80004003 Indicates that pbstrVal is a NULL pointer argument.

Remarks

A moniker is a persistent COM component that encapsulates both the ability to locate an object or data and to retrieve that object or data into memory. The display name can be used to get a pointer to the object.

Example Code

This example appears circuitous because it uses an IWMSServer method to retrieve the IWMSServer pointer by using the moniker. Typically, monikers are used because marshaling interface pointers consume more resources. Use a moniker if you are not sure that the client needs an interface pointer. Marshaling overhead is incurred only if the client binds to the moniker.

// Returns the moniker for a server.
HRESULT SampleMonikerName()
{
    BSTR bstrMoniker = NULL;
    IWMSServer *pServerFromMoniker = NULL;
    hr = pServer->get_MonikerName(&bstrMoniker);
    if (FAILED(hr)) goto EXIT;
    hr = CoGetObject(_bstr_t(bstrMoniker), NULL, 
            IID_IWMSServer, (void **)&pServerFromMoniker);
    if (FAILED(hr)) goto EXIT;

    // Verify that the moniker created the server.
    hr = pServerFromMoniker->QueryInterface(IID_IWMSServer, 
                                (void **)&pServerFromMoniker);
    if (FAILED(hr)) goto EXIT;

    return hr;
}

EXIT:
    // TODO: Release temporary COM objects and uninitialize COM.

Requirements

Header: wmsserver.h.

Library: WMSServerTypeLib.dll.

Platform: Windows ServerĀ 2003 family, Windows ServerĀ 2008 family.

See Also

Previous Next