public class MFAttributes : ComObject
Provides a generic way to store key/value pairs on an object.
MFAttributes()
Initializes a new instance of the MFAttributes class.
public void MFAttributes()
MFAttributes(Int32 initialSize)
Initializes a new instance of the MFAttributes class with a initial size.
public void MFAttributes(Int32 initialSize)
Parameters
initialSize
Int32The initial size in bytes.
MFAttributes(IntPtr ptr)
Initializes a new instance of the MFAttributes class.
public void MFAttributes(IntPtr ptr)
Parameters
ptr
IntPtrThe native pointer of the COM object.
Compare(MFAttributes theirs, MFAttributeMatchType matchType)
Compares the attributes on this object with the attributes on another object.
public Boolean Compare(MFAttributes theirs, MFAttributeMatchType matchType)
Parameters
theirs
MFAttributesThe MFAttributes interface of the object to compare with this object.
matchType
MFAttributeMatchTypeA value, specifying the type of comparison to make.
Returns
Returns true if the two sets of attributes match in the way specified by the matchType parameter; otherwise, false.
CompareItem(Guid key, PropertyVariant value)
Queries whether a stored attribute value equals a specified PropertyVariant.
public Boolean CompareItem(Guid key, PropertyVariant value)
Parameters
key
GuidGuid that identifies which value to query.
value
PropertyVariantPropertyVariant that contains the value to compare.
Returns
A boolean value indicating whether the attribute matches the value given in value.
Remarks
For more information, see .
CompareItemNative(Guid key, PropertyVariant value, NativeBool& result)
Queries whether a stored attribute value equals a specified PropertyVariant.
public Int32 CompareItemNative(Guid key, PropertyVariant value, NativeBool& result)
Parameters
key
GuidGuid that identifies which value to query.
value
PropertyVariantPropertyVariant that contains the value to compare.
result
NativeBool&Receives a boolean value indicating whether the attribute matches the value given in value.
Returns
HRESULT
Remarks
For more information, see .
CompareNative(MFAttributes theirs, MFAttributeMatchType matchType, NativeBool& result)
Compares the attributes on this object with the attributes on another object.
public Int32 CompareNative(MFAttributes theirs, MFAttributeMatchType matchType, NativeBool& result)
Parameters
theirs
MFAttributesThe MFAttributes interface of the object to compare with this object.
matchType
MFAttributeMatchTypeA value, specifying the type of comparison to make.
result
NativeBool&Receives a Boolean value. The value is True if the two sets of attributes match in the way specified by the matchType parameter. Otherwise, the value is False.
Returns
HRESULT
CopyAllItems(MFAttributes destination)
Copies all of the attributes from this object into another attribute store.
CopyAllItemsNative(MFAttributes destination)
Copies all of the attributes from this object into another attribute store.
public Int32 CopyAllItemsNative(MFAttributes destination)
Parameters
destination
MFAttributesThe attribute store that recevies the copy.
Returns
HRESULT
DeleteAllItems()
Removes all key/value pairs from the object's attribute list.
DeleteAllItemsNative()
Removes all key/value pairs from the object's attribute list.
public Int32 DeleteAllItemsNative()
Returns
HRESULT
DeleteItem(Guid key)
Removes a key/value pair from the object's attribute list.
DeleteItemNative(Guid key)
Removes a key/value pair from the object's attribute list.
public Int32 DeleteItemNative(Guid key)
Parameters
key
GuidGuid that identifies the value to delete.
Returns
HRESULT
Exists(Guid key)
Determines whether the attribute store contains an attribute with the specified key.
public Boolean Exists(Guid key)
Parameters
key
GuidThe key of the attribute.
Returns
True if the attribute exists; otherwise, false
Exceptions
MediaFoundationException
An unexpected error occurred.
Get(Guid key)
Gets the item which got associated with the specified key.
public object Get(Guid key)
Parameters
key
GuidThe key of the item.
Returns
The item which got associated with the specified key.
Exceptions
NotSupportedException
The value type of the associated item is not supported.
Get
Gets the item which got associated with the specified key.
public TValueType Get<TValueType>(Guid key)
Parameters
key
GuidThe key of the item.
Type Parameters
TValueType
Type of the returned item.
Returns
The item which got associated with the specified key.
Exceptions
NotSupportedException
The specified TValueType is not supported.
GetAllocatedBlobNative(Guid key, Byte[]& buffer, Int32& pcbSize)
Retrieves a byte array associated with a key.
public Int32 GetAllocatedBlobNative(Guid key, Byte[]& buffer, Int32& pcbSize)
Parameters
key
GuidGuid that identifies which value to retrieve. The attribute type must be Blob.
buffer
Byte[]&If the key is found and the value is a byte array, this parameter receives a copy of the array.
pcbSize
Int32&Receives the size of the array, in bytes.
Returns
HRESULT
Remarks
Obsolete, use the GetBlob method instead.
GetAllocatedStringNative(Guid key, IntPtr wszValue, Int32& cchLength)
Retrieves a wide-character string associated with a key. This method allocates the memory for the string.
public Int32 GetAllocatedStringNative(Guid key, IntPtr wszValue, Int32& cchLength)
Parameters
key
GuidGuid that identifies which value to retrieve. The attribute type must be String.
wszValue
IntPtrIf the key is found and the value is a string type, this parameter receives a copy of the string. The caller must free the memory for the string by calling FreeCoTaskMem.
cchLength
Int32&Receives the number of characters in the string, excluding the terminating NULL character.
Returns
HRESULT
Remarks
Don't use the GetAllocatedStringNative method. Use the GetString method instead.
GetBlob(Guid key)
Retrieves a byte array associated with a key.
GetBlob(Guid key, Type type)
Retrieves an object associated with a key.
public object GetBlob(Guid key, Type type)
Parameters
key
GuidGuid that identifies which value to retrieve. The attribute type must be Blob.
type
TypeThe type of the object (type of the returned object -> see return value).
Returns
The object associated with the key.
Exceptions
ArgumentNullException
Type is null.
Remarks
Internally this method retrieves a byte-array with gets converted to a instance of the specified type.
GetBlobNative(Guid key, IntPtr bufferPtr, Int32 cbBufSize, IntPtr cbBlobSize)
Retrieves a byte array associated with a key.
public Int32 GetBlobNative(Guid key, IntPtr bufferPtr, Int32 cbBufSize, IntPtr cbBlobSize)
Parameters
key
GuidGuid that identifies which value to retrieve. The attribute type must be Blob.
bufferPtr
IntPtrPointer to a buffer allocated by the caller. If the key is found and the value is a byte array, the method copies the array into this buffer. To find the required size of the buffer, call GetBlobSize.
cbBufSize
Int32The size of the bufferPtr buffer, in bytes.
cbBlobSize
IntPtrReceives the size of the byte array. This parameter can be Zero.
Returns
HRESULT
GetBlobSize(Guid key)
Retrieves the length of a byte array associated with a key.
public Int32 GetBlobSize(Guid key)
Parameters
key
GuidGuid that identifies which value to retrieve. The attribute type must be Blob.
Returns
If the key is found and the value is a byte array, this method returns the size of the array, in bytes.
GetBlobSizeNative(Guid key, Int32& size)
Retrieves the length of a byte array associated with a key.
public Int32 GetBlobSizeNative(Guid key, Int32& size)
Parameters
key
GuidGuid that identifies which value to retrieve. The attribute type must be Blob.
size
Int32&If the key is found and the value is a byte array, this parameter receives the size of the array, in bytes.
Returns
HRESULT
GetCount()
Retrieves the number of attributes that are set on this object.
GetCountNative(Int32& itemCount)
Retrieves the number of attributes that are set on this object.
public Int32 GetCountNative(Int32& itemCount)
Parameters
itemCount
Int32&Receives the number of attributes.
Returns
HRESULT
GetDouble(Guid key)
Retrieves a Double value associated with a key.
GetDoubleNative(Guid key, Double& result)
Retrieves a Double value associated with a key.
public Int32 GetDoubleNative(Guid key, Double& result)
Parameters
key
GuidGuid that identifies which value to retrieve. The attribute type must be Double.
result
Double&Receives a Double value. If the key is found and the data type is Double, the method copies the value into this parameter.
Returns
HRESULT
GetGuid(Guid key)
Retrieves a Guid value associated with a key.
GetGuidNative(Guid key, Guid& result)
Retrieves a Guid value associated with a key.
public Int32 GetGuidNative(Guid key, Guid& result)
Parameters
key
GuidGuid that identifies which value to retrieve. The attribute type must be Guid.
result
Guid&Receives a Guid value. If the key is found and the data type is Guid, the method copies the value into this parameter.
Returns
HRESULT
GetItem(Guid key)
Retrieves the value associated with a key.
GetItemByIndex(Int32 index, Guid& key)
Retrieves an attribute at the specified index.
public PropertyVariant GetItemByIndex(Int32 index, Guid& key)
Parameters
index
Int32Index of the attribute to retrieve. To get the number of attributes, call GetCount.
key
Guid&Receives the Guid that identifies this attribute.
Returns
Returns the value of the attribute specified by the index.
GetItemByIndexNative(Int32 index, Guid& key, IntPtr value)
Retrieves an attribute at the specified index.
public Int32 GetItemByIndexNative(Int32 index, Guid& key, IntPtr value)
Parameters
index
Int32Index of the attribute to retrieve. To get the number of attributes, call GetCount.
key
Guid&Receives the Guid that identifies this attribute.
value
IntPtrPointer to a PropertyVariant that receives the value. This parameter can be Zero. If it is not Zero, the method fills the PropertyVariant with a copy of the attribute value. Call Dispose to free the memory allocated by this method.
Returns
HRESULT
GetItemNative(Guid key, IntPtr valueRef)
Retrieves the value associated with a key.
public Int32 GetItemNative(Guid key, IntPtr valueRef)
Parameters
key
GuidA Guid that identifies which value to retrieve.
valueRef
IntPtrA pointer to a PropertyVariant that receives the value.
Returns
HRESULT
Remarks
For more information, see .
GetItemType(Guid key)
Retrieves the data type of the value associated with a key.
GetItemTypeNative(Guid key, MFAttributeType& attributeType)
Retrieves the data type of the value associated with a key.
public Int32 GetItemTypeNative(Guid key, MFAttributeType& attributeType)
Parameters
key
GuidGuid that identifies which value to query.
attributeType
MFAttributeType&The type of the item, associated with the specified key.
Returns
HRESULT
Remarks
For more information, see .
GetString(Guid key)
Retrieves a wide-character string associated with a key.
GetStringLength(Guid key)
Retrieves the length of a string value associated with a key.
public Int32 GetStringLength(Guid key)
Parameters
key
GuidGuid that identifies which value to retrieve. The attribute type must be String.
Returns
If the key is found and the data type is String, this method returns the number of characters in the string, not including the terminating NULL character.
GetStringLengthNative(Guid key, Int32& result)
Retrieves the length of a string value associated with a key.
public Int32 GetStringLengthNative(Guid key, Int32& result)
Parameters
key
GuidGuid that identifies which value to retrieve. The attribute type must be String.
result
Int32&If the key is found and the data type is String, this parameter receives the number of characters in the string, not including the terminating NULL character.
Returns
HRESULT
GetStringNative(Guid key, IntPtr wszValue, Int32 cchBufSize, IntPtr cchLength)
Retrieves a wide-character string associated with a key.
public Int32 GetStringNative(Guid key, IntPtr wszValue, Int32 cchBufSize, IntPtr cchLength)
Parameters
key
GuidGuid that identifies which value to retrieve. The attribute type must be String.
wszValue
IntPtrPointer to a wide-character array allocated by the caller. The array must be large enough to hold the string, including the terminating NULL character. If the key is found and the value is a string type, the method copies the string into this buffer. To find the length of the string, call GetStringLength.
cchBufSize
Int32The size of the pwszValue array, in characters. This value includes the terminating NULL character.
cchLength
IntPtrReceives the number of characters in the string, excluding the terminating NULL character. This parameter can be NULL.
Returns
HRESULT
GetUINT32(Guid key)
Retrieves a UINT32 value associated with a key.
GetUINT32Native(Guid key, Int32& result)
Retrieves a UINT32 value associated with a key.
public Int32 GetUINT32Native(Guid key, Int32& result)
Parameters
key
GuidGuid that identifies which value to retrieve. The attribute type must be UInt32.
result
Int32&Receives a UINT32 value. If the key is found and the data type is UInt32, the method copies the value into this parameter.
Returns
HRESULT
GetUINT64(Guid key)
Retrieves a UINT64 value associated with a key.
GetUINT64Native(Guid key, Int64& result)
Retrieves a UINT64 value associated with a key.
public Int32 GetUINT64Native(Guid key, Int64& result)
Parameters
key
GuidGuid that identifies which value to retrieve. The attribute type must be UInt64.
result
Int64&Receives a UINT64 value. If the key is found and the data type is UInt64, the method copies the value into this parameter.
Returns
HRESULT
GetUnknownNative(Guid key, Guid riid, IntPtr& unknown)
Retrieves an interface pointer associated with a key.
public Int32 GetUnknownNative(Guid key, Guid riid, IntPtr& unknown)
Parameters
key
GuidGuid that identifies which value to retrieve. The attribute type must be IUnknown.
riid
GuidInterface identifier (IID) of the interface to retrieve.
unknown
IntPtr&Receives a pointer to the requested interface. The caller must release the interface.
Returns
HRESULT
LockStore()
Locks the attribute store so that no other thread can access it. If the attribute store is already locked by another thread, this method blocks until the other thread unlocks the object. After calling this method, call UnlockStore to unlock the object.
LockStoreNative()
Locks the attribute store so that no other thread can access it. If the attribute store is already locked by another thread, this method blocks until the other thread unlocks the object. After calling this method, call UnlockStore to unlock the object.
public Int32 LockStoreNative()
Returns
HRESULT
Set
Sets the value of a property specified by the key of the keyValuePair object.
public void Set<T>(MFAttribute keyValuePair)
Parameters
keyValuePair
MFAttributeSpecifies the key of the property and the new value to set.
Type Parameters
T
The type of the property.
Set
Sets the value of a property specified by its key.
public void Set<TValueType>(Guid key, TValueType value)
Parameters
key
GuidThe key of the property.
value
TValueTypeThe value to set.
Type Parameters
TValueType
The type of the property.
Exceptions
NotSupportedException
The specified TValueType is not supported.
SetBlob(Guid key, Byte[] buffer)
Associates a byte array with a key.
SetBlobNative(Guid key, IntPtr buf, Int32 cbBufSize)
Associates a byte array with a key.
public Int32 SetBlobNative(Guid key, IntPtr buf, Int32 cbBufSize)
Parameters
key
GuidGuid that identifies the value to set. If this key already exists, the method overwrites the old value.
buf
IntPtrPointer to a byte array to associate with this key. The method stores a copy of the array.
cbBufSize
Int32Size of the array, in bytes.
Returns
HRESULT
SetDouble(Guid key, Double value)
Associates a Double value with a key.
SetDoubleNative(Guid key, Double value)
Associates a Double value with a key.
public Int32 SetDoubleNative(Guid key, Double value)
Parameters
key
GuidGuid that identifies the value to set. If this key already exists, the method overwrites the old value.
value
DoubleNew value for this key.
Returns
HRESULT
SetGuid(Guid key, Guid value)
Associates a Guid value with a key.
SetGuidNative(Guid key, Guid value)
Associates a Guid value with a key.
public Int32 SetGuidNative(Guid key, Guid value)
Parameters
key
GuidGuid that identifies the value to set. If this key already exists, the method overwrites the old value.
value
GuidNew value for this key.
Returns
HRESULT
SetItem(Guid key, PropertyVariant value)
Associates an attribute value with a key.
public void SetItem(Guid key, PropertyVariant value)
Parameters
key
GuidA Guid that identifies the value to set. If this key already exists, the method overwrites the old value.
value
PropertyVariantA PropertyVariant that contains the attribute value. The method copies the value. The PropertyVariant type must be one of the types listed in the MFAttributeType enumeration.
SetItemNative(Guid key, PropertyVariant value)
Associates an attribute value with a key.
public Int32 SetItemNative(Guid key, PropertyVariant value)
Parameters
key
GuidA Guid that identifies the value to set. If this key already exists, the method overwrites the old value.
value
PropertyVariantA PropertyVariant that contains the attribute value. The method copies the value. The PropertyVariant type must be one of the types listed in the MFAttributeType enumeration.
Returns
HRESULT
SetString(Guid key, String value)
Associates a wide-character string with a key.
public void SetString(Guid key, String value)
Parameters
key
GuidGuid that identifies the value to set. If this key already exists, the method overwrites the old value.
value
StringNew value for this key.
Remarks
Internally this method stores a copy of the string specified by the value parameter.
SetStringNative(Guid key, String value)
Associates a wide-character string with a key.
public Int32 SetStringNative(Guid key, String value)
Parameters
key
GuidGuid that identifies the value to set. If this key already exists, the method overwrites the old value.
value
StringNew value for this key.
Returns
HRESULT
Remarks
Internally this method stores a copy of the string specified by the value parameter.
SetUINT32(Guid key, Int32 value)
Associates a UINT32 value with a key.
SetUINT32Native(Guid key, Int32 value)
Associates a UINT32 value with a key.
public Int32 SetUINT32Native(Guid key, Int32 value)
Parameters
key
GuidGuid that identifies the value to set. If this key already exists, the method overwrites the old value.
value
Int32New value for this key.
Returns
HRESULT
SetUINT64(Guid key, Int64 value)
Associates a UINT64 value with a key.
SetUINT64Native(Guid key, Int64 value)
Associates a UINT64 value with a key.
public Int32 SetUINT64Native(Guid key, Int64 value)
Parameters
key
GuidGuid that identifies the value to set. If this key already exists, the method overwrites the old value.
value
Int64New value for this key.
Returns
HRESULT
SetUnknownNative(Guid key, IntPtr unknown)
Associates an IUnknown pointer with a key.
public Int32 SetUnknownNative(Guid key, IntPtr unknown)
Parameters
key
GuidGuid that identifies the value to set. If this key already exists, the method overwrites the old value.
unknown
IntPtrIUnknown pointer to be associated with this key.
Returns
HRESULT
UnlockStore()
Unlocks the attribute store after a call to the LockStore method. While the object is unlocked, multiple threads can access the object's attributes.
UnlockStoreNative()
Unlocks the attribute store after a call to the LockStore method. While the object is unlocked, multiple threads can access the object's attributes.
public Int32 UnlockStoreNative()
Returns
HRESULT
Count
Gets the number of attributes that are set on this object.
public Int32 Count { get; }
Item
Gets or sets an item specified by its index.
public PropertyVariant Item { get; set; }
Parameters
index
The index of the item.