mirror of https://github.com/dahall/Vanara.git
Added support for ShellItemPropertyStore to be created with a PROPERTYKEY filter or an ICreateObject
parent
c727cfa055
commit
ebbac20ca6
|
@ -326,8 +326,6 @@ namespace Vanara.Windows.Shell
|
||||||
SingleLine = 0x00000010,
|
SingleLine = 0x00000010,
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: object GetPropertyStoreForKeys(IntPtr rgKeys, uint cKeys, GPS flags, in Guid riid);
|
|
||||||
// TODO: object GetPropertyStoreWithCreateObject(GPS flags, object punkCreateObject, in Guid riid);
|
|
||||||
/// <summary>Encapsulates an item in the Windows Shell.</summary>
|
/// <summary>Encapsulates an item in the Windows Shell.</summary>
|
||||||
/// <seealso cref="System.IComparable{ShellItem}"/>
|
/// <seealso cref="System.IComparable{ShellItem}"/>
|
||||||
/// <seealso cref="System.IDisposable"/>
|
/// <seealso cref="System.IDisposable"/>
|
||||||
|
|
|
@ -30,6 +30,14 @@ namespace Vanara.Windows.Shell
|
||||||
PropertyChanged += propChangedHandler;
|
PropertyChanged += propChangedHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the ICreateObject used instead of CoCreateInstance to create an instance of the property handler associated with
|
||||||
|
/// the Shell item on which this method is called. If this value is set, <see cref="PropertyFilter"/> will be ignored.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The creator object.</value>
|
||||||
|
[DefaultValue(null)]
|
||||||
|
public ICreateObject Creator { get; set; }
|
||||||
|
|
||||||
/// <summary>Gets or sets a value indicating whether to include slow properties.</summary>
|
/// <summary>Gets or sets a value indicating whether to include slow properties.</summary>
|
||||||
/// <value><c>true</c> if including slow properties; otherwise, <c>false</c>.</value>
|
/// <value><c>true</c> if including slow properties; otherwise, <c>false</c>.</value>
|
||||||
[DefaultValue(false)]
|
[DefaultValue(false)]
|
||||||
|
@ -63,6 +71,14 @@ namespace Vanara.Windows.Shell
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a set of properties used to filter the property store. This value can be <see langword="null"/>. This value will be
|
||||||
|
/// ignored if <see cref="Creator"/> is also set.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The list of properties used to filter.</value>
|
||||||
|
[DefaultValue(null)]
|
||||||
|
public PROPERTYKEY[] PropertyFilter { get; set; }
|
||||||
|
|
||||||
/// <summary>Gets or sets a value indicating whether properties can be read and written.</summary>
|
/// <summary>Gets or sets a value indicating whether properties can be read and written.</summary>
|
||||||
/// <value><c>true</c> if properties are read/write; otherwise, <c>false</c>.</value>
|
/// <value><c>true</c> if properties are read/write; otherwise, <c>false</c>.</value>
|
||||||
[DefaultValue(true)]
|
[DefaultValue(true)]
|
||||||
|
@ -105,6 +121,11 @@ namespace Vanara.Windows.Shell
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>Gets the CLSID of a supplied property key.</summary>
|
||||||
|
/// <param name="propertyKey">The property key.</param>
|
||||||
|
/// <returns>The CLSID related to the property key.</returns>
|
||||||
|
public Guid GetCLSID(PROPERTYKEY propertyKey) => shellItem?.iShellItem2?.GetCLSID(propertyKey) ?? Guid.Empty;
|
||||||
|
|
||||||
/// <summary>The IPropertyStore instance. This can be null.</summary>
|
/// <summary>The IPropertyStore instance. This can be null.</summary>
|
||||||
protected override IPropertyStore GetIPropertyStore()
|
protected override IPropertyStore GetIPropertyStore()
|
||||||
{
|
{
|
||||||
|
@ -112,6 +133,10 @@ namespace Vanara.Windows.Shell
|
||||||
return (IPropertyStore)lnk.link;
|
return (IPropertyStore)lnk.link;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
if (Creator != null)
|
||||||
|
return shellItem?.iShellItem2?.GetPropertyStoreWithCreateObject(flags, Creator, typeof(IPropertyStore).GUID);
|
||||||
|
if (PropertyFilter != null && PropertyFilter.Length > 0)
|
||||||
|
return shellItem?.iShellItem2?.GetPropertyStoreForKeys(PropertyFilter, (uint)PropertyFilter.Length, flags, typeof(IPropertyStore).GUID);
|
||||||
return shellItem?.iShellItem2?.GetPropertyStore(flags, typeof(IPropertyStore).GUID);
|
return shellItem?.iShellItem2?.GetPropertyStore(flags, typeof(IPropertyStore).GUID);
|
||||||
}
|
}
|
||||||
catch (COMException comex) when (comex.ErrorCode == HRESULT.E_FAIL)
|
catch (COMException comex) when (comex.ErrorCode == HRESULT.E_FAIL)
|
||||||
|
@ -119,10 +144,5 @@ namespace Vanara.Windows.Shell
|
||||||
throw new InvalidOperationException($"The ShellItem does not support a property store with the flags: {flags}", comex);
|
throw new InvalidOperationException($"The ShellItem does not support a property store with the flags: {flags}", comex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Gets the CLSID of a supplied property key.</summary>
|
|
||||||
/// <param name="propertyKey">The property key.</param>
|
|
||||||
/// <returns>The CLSID related to the property key.</returns>
|
|
||||||
public Guid GetCLSID(PROPERTYKEY propertyKey) => shellItem?.iShellItem2?.GetCLSID(propertyKey) ?? Guid.Empty;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue