using System; using System.Runtime.InteropServices; using static Vanara.PInvoke.Ole32; using static Vanara.PInvoke.PropSys; namespace Vanara.PInvoke; public static partial class Shell32 { /// Provides a collection of properties associated with a file or folder. /// /// Caution /// /// You should only implement this interface if you have a specific need to do so. /// /// /// This interface can be implemented by a cloud storage provider sync engine to share properties about a file or file folder. An /// instance of IStorageProviderPropertyHandler exists for the lifetime of a storage file created under a sync root. Use /// IStorageProviderHandler to retrieve the set of properties associated with an individual file or folder. /// /// This interface is responsible for keeping track of the following properties: /// /// /// StorageProviderFileIdentifier /// /// /// StorageProviderFileRemoteUri /// /// /// StorageProviderFileChecksum /// /// /// StorageProviderFileVersionWaterline /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/storageprovider/nn-storageprovider-istorageproviderpropertyhandler [PInvokeData("storageprovider.h", MSDNShortId = "NN:storageprovider.IStorageProviderPropertyHandler")] [ComImport, Guid("301DFBE5-524C-4B0F-8B2D-21C40B3A2988"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IStorageProviderPropertyHandler { /// Gets the properties managed by the sync engine. /// The identifier for the properties to retrieve. /// The number of properties to retrieve. /// A collection of properties. /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// /// /// If the file or folder cannot be found, this method should return S_OK, but retrievedProperties should be empty. /// /// Any properties that are not managed by the sync engine should return VT_EMPTY for those properties. /// // https://docs.microsoft.com/en-us/windows/win32/api/storageprovider/nf-storageprovider-istorageproviderpropertyhandler-retrieveproperties // HRESULT RetrieveProperties( [in] const PROPERTYKEY *propertiesToRetrieve, [in] ULONG propertiesToRetrieveCount, [out] // IPropertyStore **retrievedProperties ); [PreserveSig] HRESULT RetrieveProperties([In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] PROPERTYKEY[] propertiesToRetrieve, uint propertiesToRetrieveCount, out IPropertyStore retrievedProperties); /// Saves properties associated with a file or folder. /// The properties to save. /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// Attempting to save properties that are not managed by the sync engine should result in the error code E_INVALIDARG. // https://docs.microsoft.com/en-us/windows/win32/api/storageprovider/nf-storageprovider-istorageproviderpropertyhandler-saveproperties // HRESULT SaveProperties( [in] IPropertyStore *propertiesToSave ); [PreserveSig] HRESULT SaveProperties(IPropertyStore propertiesToSave); } /// Retrieves the IStorageProviderPropertyHandler associated with a specific file or folder. /// /// Caution /// /// You should only implement this interface if you have a specific need to do so. /// // https://docs.microsoft.com/en-us/windows/win32/api/storageprovider/nn-storageprovider-istorageproviderhandler [PInvokeData("storageprovider.h", MSDNShortId = "NN:storageprovider.IStorageProviderHandler")] [ComImport, Guid("162C6FB5-44D3-435B-903D-E613FA093FB5"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IStorageProviderHandler { /// Gets an instance of IStorageProviderPropertyHandler associated with the provided path. /// The path for the relevant file. /// An IStorageProviderPropertyHandler instance associated with the file specified by path. /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. // https://docs.microsoft.com/en-us/windows/win32/api/storageprovider/nf-storageprovider-istorageproviderhandler-getpropertyhandlerfrompath // HRESULT GetPropertyHandlerFromPath( [in] LPCWSTR path, [out] IStorageProviderPropertyHandler **propertyHandler ); [PreserveSig] HRESULT GetPropertyHandlerFromPath([MarshalAs(UnmanagedType.LPWStr)] string path, out IStorageProviderPropertyHandler propertyHandler); /// Gets an instance of IStorageProviderPropertyHandler associated with the provided URI. /// The URI for the relevant file. /// An IStorageProviderPropertyHandler instance associated with the file specified by uri. /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// /// This method is used to convert a remote URI to a local file system path. That path is then used to provide the /// propertyHandler to the local file. /// // https://docs.microsoft.com/en-us/windows/win32/api/storageprovider/nf-storageprovider-istorageproviderhandler-getpropertyhandlerfromuri // HRESULT GetPropertyHandlerFromUri( [in] LPCWSTR uri, [out] IStorageProviderPropertyHandler **propertyHandler ); [PreserveSig] HRESULT GetPropertyHandlerFromUri([MarshalAs(UnmanagedType.LPWStr)] string uri, out IStorageProviderPropertyHandler propertyHandler); /// Gets an instance of IStorageProviderPropertyHandler associated with the provided file identifier. /// The identifier for the relevant file. /// An IStorageProviderPropertyHandler instance associated with the file specified by fileId. /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// /// This method is used to convert a file identifier to a local file system path. That path is then used to provide the /// propertyHandler to the local file. /// // https://docs.microsoft.com/en-us/windows/win32/api/storageprovider/nf-storageprovider-istorageproviderhandler-getpropertyhandlerfromfileid // HRESULT GetPropertyHandlerFromFileId( [in] LPCWSTR fileId, [out] IStorageProviderPropertyHandler **propertyHandler ); [PreserveSig] HRESULT GetPropertyHandlerFromFileId([MarshalAs(UnmanagedType.LPWStr)] string fileId, out IStorageProviderPropertyHandler propertyHandler); } }