/// <summary> /// Gets a <see cref="PropertyStore"/> using the specified <see cref="PropertyStore.GetFlags"/> /// </summary> /// <param name="flags">The flags to specify the PropertyStore retrieval method</param> /// <returns>The PropertyStore associated with this item</returns> public PropertyStore GetPropertyStore(PropertyStore.GetFlags flags) { IntPtr pUnk; _pItem.GetPropertyStore((GETPROPERTYSTOREFLAGS)flags, IID.IPropertyStore, out pUnk); PropertyStore store = new PropertyStore(pUnk); Marshal.Release(pUnk); return(store); }
/// <summary> /// Gets a <see cref="PropertyStore"/> containing the nominated properties using the specified <see cref="PropertyStore.GetFlags"/> /// </summary> /// <param name="flags">The flags to specify the PropertyStore retrieval method</param> /// <param name="keys">The <see cref="PropertyKey"/>s required in the store </param> /// <returns>The PropertyStore associated with this item containing the nominated properties</returns> public PropertyStore GetPropertyStoreForKeys(PropertyStore.GetFlags flags, params PropertyKey[] keys) { IntPtr arry = Marshal.AllocCoTaskMem(keys.Length + Marshal.SizeOf(typeof(PROPERTYKEY))); try { IntPtr ptr = arry; foreach (PropertyKey k in keys) { PInvoke.MoveMemory(ptr, k.MarshalledPointer, Marshal.SizeOf(typeof(PROPERTYKEY))); ptr += Marshal.SizeOf(typeof(PROPERTYKEY)); } IntPtr pUnk; _pItem.GetPropertyStoreForKeys(arry, (uint)keys.Length, (GETPROPERTYSTOREFLAGS)flags, IID.IPropertyStore, out pUnk); PropertyStore store = new PropertyStore(pUnk); Marshal.Release(pUnk); return(store); } finally { Marshal.FreeCoTaskMem(arry); } }