public object GetValue(PROPERTYKEY key) { var pv = IntPtr.Zero; object value = null; try { pv = Marshal.AllocCoTaskMem(16); m_IPropertyStore.GetValue(key, pv); try { value = PropVariant.ToObject(pv); } catch (Exception err) { throw new ApplicationException("Unsupported property data type", err); } } finally { if (pv != (IntPtr)0) { try { NativeMethods.PropVariantClear(pv); } catch { Debug.Fail("VariantClear failure"); } Marshal.FreeCoTaskMem(pv); pv = IntPtr.Zero; } } return(value); }
public PropertyDescription GetPropertyDescription(PROPERTYKEY propKey) { var IID_IPropertyDescription = typeof(NativeMethods.IPropertyDescription).GUID; NativeMethods.IPropertyDescription iPropertyDescription; m_IPropertySystem.GetPropertyDescription(propKey, ref IID_IPropertyDescription, out iPropertyDescription); return(new PropertyDescription(iPropertyDescription)); }
public void SetValue(PROPERTYKEY key, object value) { var pv = IntPtr.Zero; try { pv = NativeMethods.PropVariantFromObject(value); m_IPropertyStore.SetValue(key, pv); } finally { if (pv != IntPtr.Zero) { NativeMethods.PropVariantClear(pv); Marshal.FreeCoTaskMem(pv); pv = IntPtr.Zero; } } }