IWbemPropertyProvider::GetProperty method

The IWbemPropertyProvider::GetProperty method is called by Windows Management to retrieve an individual property value.

Syntax


HRESULT GetProperty(
  [in]   long lFlags,
  [in]   const BSTR strLocale,
  [in]   const BSTR strClassMapping,
  [in]   const BSTR strInstMapping,
  [in]   const BSTR strPropMapping,
  [out]  VARIANT *pvValue
);

Parameters

lFlags [in]

Reserved. This parameter must be 0.

strLocale [in]

String indicating the desired locale in cases where the returned property value can be localized. If the property cannot be localized, the implementation can ignore this value.

strClassMapping [in]

Literal copy of the string value for the ClassContext qualifier for the class. This points to a valid BSTR, which is treated as read-only, or NULL if the qualifier does not exist.

strInstMapping [in]

Literal copy of the string value for the InstanceContext qualifier for the instance. This must point to a valid BSTR, which is treated as read-only, or NULL if the qualifier does not exist.

strPropMapping [in]

Literal copy of the value of the PropertyContext qualifier for the property. This must point to a valid BSTR, which is treated as read-only, or NULL if the qualifier does not exist.

pvValue [out]

Pointer to an uninitialized VARIANT that receives the value for the property. The implementation must call VariantInit and return the value. If an error occurs, the implementation is expected to ignore the pointer.

Return value

This method must return WBEM_S_NO_ERROR if the call succeeds. If the call fails, the method must return WBEM_S_FALSE.

Examples

The following code example describes how to implement GetProperty.


STDMETHODIMP CMyPropProvider::GetProperty(
            long lFlags,
            BSTR Locale,
            BSTR ClassMapping,
            BSTR InstMapping,
            BSTR PropMapping,
            VARIANT *pvValue)
{
    SCODE sc = WBEM_S_NO_ERROR;

    if(!_wcsicmp(PropMapping, L"GiveMeANumber!"))
    {
        pvValue->vt = VT_I4;
        pvValue->lVal = 27;
    }
    else
    {
        pvValue->vt = VT_BSTR;
        pvValue->bstrVal = SysAllocString(L"Hello World");
        if(pvValue->bstrVal == NULL)
            sc = WBEM_E_OUT_OF_MEMORY;
    }
    return sc;
}

Requirements

Minimum supported client

Windows Vista

Minimum supported server

Windows Server 2003

Header

Wbemprov.h (include Wbemidl.h)

Library

Wbemuuid.lib

DLL

Wbemsvc.dll

See also

IWbemPropertyProvider
Constructing Property Providers
PutProperty

 

 

Show:
© 2015 Microsoft