IWMDMMetaData::QueryByIndex
The QueryByIndex method retrieves the value of a property by specifying its index.
Syntax
HRESULT QueryByIndex(
UINT iIndex,
WCHAR** ppwszName,
WMDM_TAG_DATATYPE* pType,
BYTE** ppValue,
UINT* pcbLength
);
Parameters
iIndex
[in] Integer containing the zero-based index of the property. The number of items is obtained through the GetItemCount call.
ppwszName
[out] Pointer to a pointer that receives a wide-character null-terminated string containing the name. Caller should free the memory through the CoTaskMemFree Method.
pType
[out] Pointer to a variable containing one member of the WMDM_TAG_DATATYPE enumeration type.
ppValue
[out] Pointer to a pointer to a byte array that receives the content of the value if the method succeeds. The caller must free the memory through the CoTaskMemFree method.
pcbLength
[out] Pointer to the size, in bytes, of the byte array ppValue.
Return Values
The method returns an HRESULT. All the interface methods in Windows Media Device Manager and service provider can return any of the following classes of error codes:
- Standard COM error codes
- Windows error codes converted to HRESULT values
- Windows Media Device Manager error codes
For a complete list of possible error codes, see Error Codes.
Possible values include, but are not limited to, those in the following table.
Value | Description |
S_OK | The method succeeded. |
E_OUTOFMEMORY | There is not enough memory to allocate the item. |
E_INVALIDARG | One or more parameters are invalid. |
Example Code
// Assume that the parameter pMetaData is valid.
UINT count;
hr = pMetaData->GetItemCount(&count);
if(FAILED(hr))
{
return hr;
}
WMDM_TAG_DATATYPE Type;
UINT i;
WCHAR *valStr;
DWORD dwVal;
BOOL fVal;
for(i =0; i < count; i++)
{
valueSize = 0;
value = NULL;
name = NULL;
hr = pMetaData->QueryByIndex(i, &name, &type, &value, &valueSize);
if(SUCCEEDED(hr))
{
if(value != NULL && name != NULL)
{
switch (type)
{
case WMDM_TYPE_STRING:
valStr = (WCHAR *)value;
if(0 == wcscmp(g_wszWMDMTitle, name))
{
// Do something with parameter valStr.
}
else if(0 == wcscmp(g_wszWMDMAuthor, name) )
{
// Do something with parameter valStr.
}
break;
case WMDM_TYPE_DWORD:
dwVal = *(DWORD *)value;
// Do something with parameter valStr.
break;
case WMDM_TYPE_BOOL:
fVal = *(BOOL *)value;
break;
default:
// Do not care.
break;
}
}
if(value)
{
CoTaskMemFree(value);
}
if(name)
{
CoTaskMemFree( name );
}
}
}
Requirements
Header: Defined in wmdm.idl.
Library: mssachlp.lib
See Also