/// <summary> /// Retrieves a string associated with a key. /// </summary> /// <param name="attributes">A valid IMFAttributes instance.</param> /// <param name="guidKey">Guid that identifies which value to retrieve.</param> /// <param name="value">Receives the string.</param> /// <returns>If this function succeeds, it returns the S_OK member. Otherwise, it returns another HResult's member that describe the error.</returns> public static HResult GetString(this IMFAttributes attributes, Guid guidKey, out string value) { if (attributes == null) { throw new ArgumentNullException("attributes"); } value = null; int stringLength; HResult hr = attributes.GetStringLength(guidKey, out stringLength); if (hr.Failed()) { return(hr); } StringBuilder sb = new StringBuilder(stringLength + 1); hr = attributes.GetString(guidKey, sb, sb.Capacity, out stringLength); if (hr.Failed()) { return(hr); } value = sb.ToString(); return(hr); }
public HResult GetString(Guid guidKey, StringBuilder pwszValue, int cchBufSize, out int pcchLength) { return(m_Attribs.GetString(guidKey, pwszValue, cchBufSize, out pcchLength)); }
public static string GetString(this IMFAttributes obj, Guid key, string defaultValue = null) { if (obj == null) { throw new ArgumentNullException(nameof(obj)); } if (obj.GetStringLength(key, out var length).IsError) { return(defaultValue); } var s = new string('\0', (int)length); length++; obj.GetString(key, s, length, ref length).ThrowOnError(); return(s); }