IWMDMMetaData::AddItem
The AddItem method adds a metadata property to the interface.
Syntax
HRESULT AddItem(WMDM_TAG_DATATYPEType,LPCWSTRpwszTagName,BYTE*pValue,UINTiLength);
Parameters
Type
[in] An WMDM_TAG_DATATYPE enumerated value specifying the type of metadata being saved.
pwszTagName
[in] Pointer to a wide-character, null-terminated string specifying the name of the property to set. A list of standard property name constants is given in Metadata Constants.
pValue
[in] Pointer to a byte array specifying the value to assign to the property. The submitted value is copied, so the memory can be freed after calling AddItem.
iLength
[in] Integer specifying the size of pValue, in bytes.
Return Values
The method returns an HRESULT. All the interface methods in Windows Media Device Manager 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 an extenstive 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
The following code adds an author metadata value to an IWMDMMetaData interface (pMetadata), and checks for returned errors with a custom macro.
WCHAR* author = L"Gudmundur Axel Hansen";
UINT numBytes = (wcslen(author) + 1) * sizeof(WCHAR); // WCHAR string is length + 1 for termination character.
hr = pMetadata->AddItem(WMDM_TYPE_STRING, g_wszWMDMAuthor, (BYTE*)author, numBytes) ;
BREAK_HR(hr,"Created an IWMDMMetaData interface in mySendFile.","Couldn't create an IWMDMMetaData interface in mySendFile.");
Requirements
Header: Defined in mswmdm.h.
Library: mssachlp.lib
See Also