diff --git a/Windows.Shell/ShellObjects/ShellItem.cs b/Windows.Shell/ShellObjects/ShellItem.cs index 97d427de..a869caf0 100644 --- a/Windows.Shell/ShellObjects/ShellItem.cs +++ b/Windows.Shell/ShellObjects/ShellItem.cs @@ -326,8 +326,6 @@ namespace Vanara.Windows.Shell SingleLine = 0x00000010, } - // TODO: object GetPropertyStoreForKeys(IntPtr rgKeys, uint cKeys, GPS flags, in Guid riid); - // TODO: object GetPropertyStoreWithCreateObject(GPS flags, object punkCreateObject, in Guid riid); /// Encapsulates an item in the Windows Shell. /// /// diff --git a/Windows.Shell/ShellProperties/ShellItemPropertyStore.cs b/Windows.Shell/ShellProperties/ShellItemPropertyStore.cs index 6387abad..31aad621 100644 --- a/Windows.Shell/ShellProperties/ShellItemPropertyStore.cs +++ b/Windows.Shell/ShellProperties/ShellItemPropertyStore.cs @@ -30,6 +30,14 @@ namespace Vanara.Windows.Shell PropertyChanged += propChangedHandler; } + /// + /// 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, will be ignored. + /// + /// The creator object. + [DefaultValue(null)] + public ICreateObject Creator { get; set; } + /// Gets or sets a value indicating whether to include slow properties. /// true if including slow properties; otherwise, false. [DefaultValue(false)] @@ -63,6 +71,14 @@ namespace Vanara.Windows.Shell } } + /// + /// Gets or sets a set of properties used to filter the property store. This value can be . This value will be + /// ignored if is also set. + /// + /// The list of properties used to filter. + [DefaultValue(null)] + public PROPERTYKEY[] PropertyFilter { get; set; } + /// Gets or sets a value indicating whether properties can be read and written. /// true if properties are read/write; otherwise, false. [DefaultValue(true)] @@ -105,6 +121,11 @@ namespace Vanara.Windows.Shell } } + /// Gets the CLSID of a supplied property key. + /// The property key. + /// The CLSID related to the property key. + public Guid GetCLSID(PROPERTYKEY propertyKey) => shellItem?.iShellItem2?.GetCLSID(propertyKey) ?? Guid.Empty; + /// The IPropertyStore instance. This can be null. protected override IPropertyStore GetIPropertyStore() { @@ -112,6 +133,10 @@ namespace Vanara.Windows.Shell return (IPropertyStore)lnk.link; 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); } 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); } } - - /// Gets the CLSID of a supplied property key. - /// The property key. - /// The CLSID related to the property key. - public Guid GetCLSID(PROPERTYKEY propertyKey) => shellItem?.iShellItem2?.GetCLSID(propertyKey) ?? Guid.Empty; } } \ No newline at end of file