IWMHeaderInfo::SetAttribute method

The SetAttribute method sets a descriptive attribute that is stored in the header section of the ASF file. This method is replaced by IWMHeaderInfo3::AddAttribute, and should not be used.


HRESULT SetAttribute(
  [in]       WORD              wStreamNum,
  [in]       LPCWSTR           pszName,
  [in]       WMT_ATTR_DATATYPE Type,
  [inconst BYTE              *pValue,
  [in]       WORD              cbLength


wStreamNum [in]

WORD containing the stream number. To set a file-level attribute, pass zero.

pszName [in]

Pointer to a wide-character null-terminated string containing the name of the attribute. Attribute names are limited to 1024 wide characters.

Type [in]

A value from the WMT_ATTR_DATATYPE enumeration type.

pValue [in]

Pointer to a byte array containing the value of the attribute.

cbLength [in]

The size of pValue, in bytes.

Return value

The method returns an HRESULT. Possible values include, but are not limited to, those in the following table.

Return codeDescription

The method succeeded.


A parameter does not contain a valid value.


Not implemented.


The method failed for an unspecified reason.


The object is not in a configurable state, or no profile has been set.



Refer to the Attributes section for a list of predefined attributes. For predefined attributes, the Type parameter must match the data type defined for that attribute. For custom attributes, you can specify any type except WMT_TYPE_GUID, but the buffer size (given by cbLength) must match the type. See WMT_ATTR_DATATYPE for more information.

The IWMHeaderInfo interface does not support the WMT_TYPE_GUID data type. To use this data type, you must use the methods of the IWMHeaderInfo3 interface.

Attributes in MP3 files cannot be specific to a particular stream. For MP3 files, always set the stream number to zero. When setting attributes for MP3 files, the metadata editor will automatically insert a byte-order mark in accordance with the Unicode specification. If you manually insert a byte-order mark, this method will not fail, but the value will then have two marks, which can cause problems when reading the attribute.

This method does not support attributes with values larger than 64 kilobytes. To include large attributes in your file, use the methods of the IWMHeaderInfo3 interface.

The writer object supports this method only before the IWMWriter::BeginWriting method has been called. The reader and synchronous reader objects do not support this method.

Before you can use this method through the IWMHeaderInfo interface of a writer object to set DRM attributes, you must set a profile for the writer to use.

The objects of the Windows Media Format SDK perform type checking on some supported metadata attributes, but not all of them. You should ensure that any attributes you use are set using the data type specified in the Attributes section of this documentation. Likewise, you cannot assume that an attribute set by another application will use the correct data type.


Minimum supported client

Windows 2000 Professional [desktop apps only]

Minimum supported server

Windows 2000 Server [desktop apps only]


Windows Media Format 7 SDK, or later versions of the SDK


Wmsdkidl.h (include Wmsdk.h)


WMStubDRM.lib (if you use DRM)

See also

IWMHeaderInfo Interface
IWMHeaderInfo3 Interface



Community Additions

© 2016 Microsoft