using System; using System.Runtime.InteropServices; namespace Vanara.PInvoke { public static partial class Ole32 { /// /// Instantiates the appropriate interceptor for the specified interface to be intercepted and returns the newly created interceptor. /// /// A reference to the identifier of the interface for which an interceptor is to be returned. /// /// If this parameter is NULL, the object is not being created as part of an aggregate. Otherwise, this parameter is a pointer /// to the aggregate object's IUnknown interface (the controlling IUnknown). /// /// A reference to the identifier of the interface desired on the interceptor. /// /// The address of a pointer variable that receives the interface pointer requested in iid. Upon successful return, **ppv contains /// the requested interceptor pointer. /// /// /// This function can return the following values. /// /// /// Return code /// Description /// /// /// S_OK /// The function returned successfully. /// /// /// E_UNEXPECTED /// An unexpected error occurred. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/callobj/nf-callobj-cogetinterceptor HRESULT CoGetInterceptor( REFIID // iidIntercepted, IUnknown *punkOuter, REFIID iid, void **ppv ); [DllImport(Lib.Ole32, SetLastError = false, ExactSpelling = true)] [PInvokeData("callobj.h", MSDNShortId = "d1ffee1d-f907-4091-b993-cf13d8ce616c")] public static extern HRESULT CoGetInterceptor(in Guid iidIntercepted, [MarshalAs(UnmanagedType.IUnknown), Optional] object punkOuter, in Guid iid, [MarshalAs(UnmanagedType.IUnknown)] out object ppv); /// /// The StgConvertVariantToProperty function converts a PROPVARIANT data type to a SERIALIZEDPROPERTYVALUE data type. /// /// A pointer to PROPVARIANT. /// A property set codepage. /// Optional. A pointer to SERIALIZEDPROPERTYVALUE. /// A pointer to the remaining stream length, updated to the actual property size on return. /// The propid (used if indirect). /// Reserver. The value must be FALSE. /// Optional. A pointer to the indirect property count. /// Returns a pointer to SERIALIZEDPROPERTYVALUE. /// /// This function converts a PROPVARIANT to a property. If the function fails it throws an exception that represents /// STATUS_INVALID_PARAMETER NT_STATUS. /// // https://docs.microsoft.com/en-us/windows/win32/api/propidl/nf-propidl-stgconvertvarianttoproperty SERIALIZEDPROPERTYVALUE * // StgConvertVariantToProperty( const PROPVARIANT *pvar, USHORT CodePage, SERIALIZEDPROPERTYVALUE *pprop, ULONG *pcb, PROPID pid, // BOOLEAN fReserved, ULONG *pcIndirect ); [DllImport(Lib.Ole32, SetLastError = false, ExactSpelling = true)] [PInvokeData("propidl.h", MSDNShortId = "3d35b808-4fa6-44ec-9c46-96ceee1dafd0")] public static extern IntPtr StgConvertVariantToProperty([In] PROPVARIANT pvar, ushort CodePage, [Optional] IntPtr pprop, ref uint pcb, uint pid, [MarshalAs(UnmanagedType.U1), Optional] bool fReserved, ref uint pcIndirect); /// /// The StgPropertyLengthAsVariant function examines a SERIALIZEDPROPERTYVALUE and returns the amount of memory that /// this property would occupy as a PROPVARIANT. /// /// A pointer to a SERIALIZEDPROPERTYVALUE. /// The size of the pProp buffer in bytes. /// A property set code page. /// Reserved. Must be 0. /// Returns the amount of memory the property would occupy as a PROPVARIANT. /// /// Use this function to decide whether or not to deserialize a property value in a low-memory scenario. Most applications will have /// no need to call this function. /// // https://docs.microsoft.com/en-us/windows/win32/api/propapi/nf-propapi-stgpropertylengthasvariant ULONG StgPropertyLengthAsVariant( // const SERIALIZEDPROPERTYVALUE *pProp, ULONG cbProp, USHORT CodePage, BYTE bReserved ); [DllImport(Lib.Ole32, SetLastError = false, ExactSpelling = true)] [PInvokeData("propapi.h", MSDNShortId = "3e809ca9-3038-4d92-bb56-23bd45b6b644")] public static extern uint StgPropertyLengthAsVariant(IntPtr pProp, uint cbProp, ushort CodePage, byte bReserved = 0); } }