using System; using System.Runtime.InteropServices; namespace Vanara.PInvoke { public static partial class Shell32 { /// /// Exposes a method to initialize a handler, such as a property handler, thumbnail handler, or preview handler, with a file path. /// /// /// Whenever possible, it is recommended that initialization be done through a stream using IInitializeWithStream. Benefits of this /// include increased security and stability. /// // https://docs.microsoft.com/en-us/windows/desktop/api/propsys/nn-propsys-iinitializewithfile [PInvokeData("propsys.h", MSDNShortId = "323181ab-1dc2-4b2a-a91f-3eccd7968bcd")] [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("b7d14566-0509-4cce-a71f-0a554233bd9b")] public interface IInitializeWithFile { /// /// Initializes a handler with a file path. /// /// /// Type: LPCWSTR /// A pointer to a buffer that contains the file path as a null-terminated Unicode string. /// /// /// Type: DWORD /// One of the following STGM values that indicates the access mode for . /// STGM_READ /// The file indicated by IInitializeWithFile::Initialize is read-only. /// STGM_READWRITE /// The file indicated by IInitializeWithFile::Initialize can be read from and written to. /// /// /// Type: HRESULT /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// /// /// /// Initialize is preferred to this method because of its ability to use files that are not accessible through a Win32 path, such /// as the contents of a compressed file with a .zip file name extension. Use IInitializeWithFile::Initialize only when /// the API used by the handler to access the file accepts file paths only. /// /// The file pointed to by must remain open for the lifetime of the handler or until IPropertyStore::Commit is called. /// If the file cannot be opened according to the method's parameter values, this method returns a suitable error code. /// /// A handler instance should be initialized only once in its lifetime. Attempts by the calling application to reinitialize the /// handler should result in the error . /// /// [PreserveSig] HRESULT Initialize([In, MarshalAs(UnmanagedType.LPWStr)] string pszFilePath, STGM grfMode); } } }