using System; using System.Runtime.InteropServices; using static Vanara.PInvoke.Ole32; namespace Vanara.PInvoke { public static partial class PropSys { /// Describes property change array behavior. [PInvokeData("Propsys.h")] public enum PKA_FLAGS { /// Replace current value. PKA_SET = 0, /// Append to current value - multi-value properties only. PKA_APPEND = 1, /// Delete from current value - multi-value properties only. PKA_DELETE = 2 } /// Exposes methods for getting and setting the property key. [PInvokeData("Propsys.h", MSDNShortId = "bb775404")] [ComImport, Guid("fc0ca0a7-c316-4fd2-9031-3e628e6d4f23"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IObjectWithPropertyKey { /// Sets the property key. /// The property key. void SetPropertyKey(ref PROPERTYKEY key); /// Gets the property key. /// When this returns, contains the property key. PROPERTYKEY GetPropertyKey(); } /// Exposes a method that encapsulates a change to a single property. /// [PInvokeData("Propsys.h", MSDNShortId = "bb775244")] [ComImport, Guid("f917bc8a-1bba-4478-a245-1bde03eb9431"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IPropertyChange : IObjectWithPropertyKey { /// Sets the property key. /// The property key. new void SetPropertyKey(ref PROPERTYKEY key); /// Gets the property key. /// When this returns, contains the property key. new PROPERTYKEY GetPropertyKey(); /// Applies a change to a property value. /// A reference to a source PROPVARIANT structure. /// A pointer to a changed PROPVARIANT structure. void ApplyToPropVariant([In] PROPVARIANT propvarIn, out PROPVARIANT ppropvarOut); } /// Exposes methods for several multiple change operations that may be passed to IFileOperation. [PInvokeData("Propsys.h", MSDNShortId = "bb775223")] [ComImport, Guid("380f5cad-1b5e-42f2-805d-637fd392d31e"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IPropertyChangeArray { /// Gets the number of change operations in the array. /// The number of change operations. uint GetCount(); /// Gets the change operation at a specified array index. /// The index of the change to retrieve. /// A reference to the desired IID. /// The address of a pointer to the interface specified by riid, usually IPropertyChange. [return: MarshalAs(UnmanagedType.Interface)] object GetAt([In] uint iIndex, in Guid riid); /// Inserts a change operation into an array at the specified position. /// The index at which the change is inserted. /// A pointer to the interface that contains the change. void InsertAt([In] uint iIndex, [In] IPropertyChange ppropChange); /// Inserts a change operation at the end of an array. /// A pointer to the interface that contains the change. void Append([In] IPropertyChange ppropChange); /// Replaces the first occurrence of a change that affects the same property key as the provided change. If the property key is not already in the array, this method appends the change to the end of the array. /// A pointer to the interface that contains the change. void AppendOrReplace([In] IPropertyChange ppropChange); /// Removes a specified change. /// The index of the change to remove. void RemoveAt([In] uint iIndex); /// Specifies whether a particular property key exists in the change array. /// A reference to the PROPERTYKEY structure of interest. [PreserveSig] HRESULT IsKeyInArray(in PROPERTYKEY key); } /// Creates a container for a set of IPropertyChange objects. This container can be used with IFileOperation to apply a set of property changes to a set of files. /// Pointer to an array of PROPERTYKEY structures that name the specific properties whose changes are being stored. If this value is NULL, cChanges must be 0. /// Pointer to an array of PKA_FLAGS values. If this value is NULL, cChanges must be 0. /// Pointer to an array of PROPVARIANT structures. If this value is NULL, cChanges must be 0. /// Count of changes to be applied. This is the number of elements in each of the arrays rgpropkey, rgflags, and rgpropvar. /// Reference to the ID of the requested interface. /// When this function returns, contains the interface pointer requested in riid. This is typically IPropertyChangeArray. /// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. [DllImport(Lib.PropSys, ExactSpelling = true)] [PInvokeData("Propsys.h", MSDNShortId = "bb776491")] public static extern HRESULT PSCreatePropertyChangeArray( [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] PROPERTYKEY[] rgpropkey, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] PKA_FLAGS[] rgflags, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] PROPVARIANT[] rgpropvar, uint cChanges, in Guid riid, out IPropertyChangeArray ppv); /// Creates a simple property change. /// PKA_FLAGS flags. /// Reference to a PROPERTYKEY structure. /// Reference to a PROPVARIANT structure. /// Reference to a specified IID. /// The address of an IPropertyChange interface pointer. /// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. [DllImport(Lib.PropSys, ExactSpelling = true)] [PInvokeData("Propsys.h", MSDNShortId = "bb776494")] public static extern HRESULT PSCreateSimplePropertyChange([In] PKA_FLAGS flags, in PROPERTYKEY key, [In] PROPVARIANT propvar, in Guid riid, out IPropertyChange ppv); } }