IWMSNamedValue Interface
You can use the IWMSNamedValue interface to specify the name and retrieve or specify the value of a name-value pair associated with the server. You can use the IWMSNamedValues interface to manage a collection of name-value pairs.
In addition to the methods inherited from IDispatch, the IWMSNamedValue interface exposes the following methods.
Method |
Description |
---|---|
get_Name |
Retrieves the name portion of the name-value pair. |
get_Value |
Retrieves the value portion of the name-value pair. |
put_Value |
Sets the value portion of the name-value pair. |
Example
The following example illustrates how to retrieve a pointer to an IWMSNamedValue interface.
#include <windows.h>
#include <atlbase.h> // Includes CComVariant.
#include "wmsserver.h"
// Declare variables and interfaces.
IWMSServer *pServer;
IWMSNamedValues *pNamedValues;
IWMSNamedValue *pNamedValue;
HRESULT hr;
CComVariant varIndex;
long lCount;
// Initialize the COM library and retrieve a pointer
// to an IWMSServer interface.
hr = CoInitialize(NULL);
hr = CoCreateInstance(CLSID_WMSServer,
NULL,
CLSCTX_ALL,
IID_IWMSServer,
(void **)&pServer);
if (FAILED(hr)) goto EXIT;
// Retrieve a pointer to an IWMSNamedValues interface
// containing descriptive information about the server.
hr = pServer->get_Properties(&pNamedValues);
if (FAILED(hr)) goto EXIT;
// Retrieve the total count of name-value pairs.
hr = pNamedValues->get_Count(&lCount);
if (FAILED(hr)) goto EXIT;
// Retrieve information about each name-value pair.
for (long x = 0; x < lCount; x++) {
varIndex = x;
hr = pNamedValues->get_Item(varIndex, &pNamedValue);
if (FAILED(hr)) goto EXIT;
// Release temporary COM objects.
pNamedValue->Release();
}
System and custom plug-ins contain some default name-value pairs that can be accessed by simply indexing the name of the property you want to retrieve. For a list of the default values you can access, see Registering Plug-in Properties.
The following example illustrates how to retrieve one of the default configuration values.
// Declare variables and interfaces.
IWMSServer *pServer;
IWMSPlugins *pPlugins;
IWMSPlugin *pPlugin;
IWMSNamedValues *pNamedValues;
IWMSNamedValue *pNamedValue;
HRESULT hr;
CComVariant varIndex;
CComVariant varValue;
// Retrieve a pointer to an IWMSPlugins interface
// containing event-handler plug-ins.
hr = pServer->get_EventHandlers(&pPlugins);
if (FAILED(hr)) goto EXIT;
// Retrieve a pointer to an IWMSPlugin interface.
varIndex = "WMS IP Address Authorization";
hr = pPlugins->get_Item(varIndex, &pPlugin);
if (FAILED(hr)) goto EXIT;
// Retrieve a pointer to an IWMSNamedValues interface
// containing descriptive information about the plug-in.
hr = pPlugin->get_Properties(&pNamedValues);
if (FAILED(hr)) goto EXIT;
// Retrieve the default name-value pair
// describing the plug-in author.
varIndex = "Author";
hr = pNamedValues->get_Item(varIndex, &pNamedValue);
if (FAILED(hr)) goto EXIT;
// Retrieve the value associated with this pair.
hr = pNamedValue->get_Value(&varValue);
if (FAILED(hr)) goto EXIT;
EXIT:
// TODO: Release temporary COM objects and uninitialize COM.