/// <summary> /// /// </summary> /// <param name="iPropertyDescription"></param> /// <remarks> /// <para>In order to avoid having to make this class disposable, it retrieves all values /// from IPropertyDescription in the constructor. The caller should release iPropertyDescription. /// </para> /// </remarks> internal PropertyDescription(PropertyStoreInterop.IPropertyDescription iPropertyDescription) { Int32 hResult; // Get Property Key hResult = iPropertyDescription.GetPropertyKey(out m_propertyKey); if (hResult < 0) { Marshal.ThrowExceptionForHR(hResult); } // Get Canonical Name IntPtr pszName = IntPtr.Zero; try { hResult = iPropertyDescription.GetCanonicalName(out pszName); if (hResult >= 0 && pszName != IntPtr.Zero) { m_canonicalName = Marshal.PtrToStringUni(pszName); } else { Marshal.ThrowExceptionForHR(hResult); } } finally { if (pszName != IntPtr.Zero) { Marshal.FreeCoTaskMem(pszName); pszName = IntPtr.Zero; } } // Get Display Name pszName = IntPtr.Zero; try { hResult = iPropertyDescription.GetDisplayName(out pszName); if (hResult >= 0 && pszName != IntPtr.Zero) { m_displayName = Marshal.PtrToStringUni(pszName); } else { m_displayName = null; } } finally { if (pszName != IntPtr.Zero) { Marshal.FreeCoTaskMem(pszName); pszName = IntPtr.Zero; } } // Get Type hResult = iPropertyDescription.GetPropertyType(out m_vt); if (hResult < 0) { m_vt = 0; Debug.Fail("IPropertyDescription.GetPropertyType failed."); } // Get Type Flags hResult = iPropertyDescription.GetTypeFlags(PROPDESC_TYPE_FLAGS.PDTF_MASK_ALL, out m_typeFlags); if (hResult < 0) { m_typeFlags = 0; Debug.Fail("IPropertyDescription.GetTypeFlags failed."); } #if !RAW_PROPERTY_STORE if (s_ForceInnate.Contains(m_propertyKey)) { m_typeFlags |= PROPDESC_TYPE_FLAGS.PDTF_ISINNATE; } #endif // Get View Flags hResult = iPropertyDescription.GetViewFlags(out m_viewFlags); if (hResult < 0) { m_viewFlags = 0; Debug.Fail("IPropertyDescription.GetViewFlags failed."); } // Get Display type hResult = iPropertyDescription.GetDisplayType(out m_displayType); if (hResult < 0) { m_displayType = 0; Debug.Fail("IPropertyDescription.GetDisplayType failed."); } }
internal _ViewFlags(PROPDESC_VIEW_FLAGS flags) { _flags = flags; }