File: Windows.Win32.IOleAdviseHolder.g.cs
Project: src\src\System.Windows.Forms.Primitives\src\System.Windows.Forms.Primitives.csproj (System.Windows.Forms.Primitives)
// ------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
// ------------------------------------------------------------------------------

#pragma warning disable CS1591,CS1573,CS0465,CS0649,CS8019,CS1570,CS1584,CS1658,CS0436,CS8981
using global::System;
using global::System.Diagnostics;
using global::System.Diagnostics.CodeAnalysis;
using global::System.Runtime.CompilerServices;
using global::System.Runtime.InteropServices;
using global::System.Runtime.Versioning;
using winmdroot = global::Windows.Win32;
namespace Windows.Win32
{
	namespace System.Ole
	{
		[Guid("00000111-0000-0000-C000-000000000046")]
		[SupportedOSPlatform("windows5.0")]
		[global::System.CodeDom.Compiler.GeneratedCode("Microsoft.Windows.CsWin32", "0.3.151+58e949951d.RR")]
		internal unsafe partial struct IOleAdviseHolder
			:IVTable<IOleAdviseHolder,IOleAdviseHolder.Vtbl>,IComIID		{
			/// <inheritdoc cref="QueryInterface(global::System.Guid*, void**)"/>
			internal unsafe winmdroot.Foundation.HRESULT QueryInterface(in global::System.Guid riid, out void* ppvObject)
			{
				fixed (void** ppvObjectLocal = &ppvObject)
				{
					fixed (global::System.Guid* riidLocal = &riid)
					{
						winmdroot.Foundation.HRESULT __result = this.QueryInterface(riidLocal, ppvObjectLocal);
						return __result;
					}
				}
			}

			public unsafe winmdroot.Foundation.HRESULT QueryInterface(global::System.Guid* riid, void** ppvObject)
			{
				return ((delegate *unmanaged [Stdcall]<IOleAdviseHolder*,global::System.Guid* ,void** ,winmdroot.Foundation.HRESULT>)lpVtbl[0])((IOleAdviseHolder*)Unsafe.AsPointer(ref this), riid, ppvObject);
			}

			public uint AddRef()
			{
				return ((delegate *unmanaged [Stdcall]<IOleAdviseHolder*,uint>)lpVtbl[1])((IOleAdviseHolder*)Unsafe.AsPointer(ref this));
			}

			public uint Release()
			{
				return ((delegate *unmanaged [Stdcall]<IOleAdviseHolder*,uint>)lpVtbl[2])((IOleAdviseHolder*)Unsafe.AsPointer(ref this));
			}

			/// <inheritdoc cref="Advise(winmdroot.System.Com.IAdviseSink*, uint*)"/>
			internal unsafe winmdroot.Foundation.HRESULT Advise(winmdroot.System.Com.IAdviseSink* pAdvise, out uint pdwConnection)
			{
				fixed (uint* pdwConnectionLocal = &pdwConnection)
				{
					winmdroot.Foundation.HRESULT __result = this.Advise(pAdvise, pdwConnectionLocal);
					return __result;
				}
			}

			[UnmanagedCallersOnly(CallConvs = new []{
typeof(CallConvStdcall)}
)]
			private static winmdroot.Foundation.HRESULT Advise(IOleAdviseHolder* pThis, winmdroot.System.Com.IAdviseSink* pAdvise, uint* pdwConnection)
			{
				try
				{
					winmdroot.Foundation.HRESULT __hr = ComHelpers.UnwrapCCW(pThis, out Interface __object);
					if (__hr.Failed)
					{
						return __hr;
					}
					return __object.Advise(pAdvise, pdwConnection);
				}
				catch (Exception ex)
				{
					return (winmdroot.Foundation.HRESULT)ex.HResult;
				}
			}

			/// <summary>Establishes an advisory connection between an OLE object and the calling object's advise sink. Through that sink, the calling object can receive notification when the OLE object is renamed, saved, or closed.</summary>
			/// <param name="pAdvise">A pointer to the <a href="https://docs.microsoft.com/windows/desktop/api/objidl/nn-objidl-iadvisesink">IAdviseSink</a> interface on the advisory sink that should be informed of changes.</param>
			/// <param name="pdwConnection">A pointer to a token that can be passed to the <a href="https://docs.microsoft.com/windows/desktop/api/oleidl/nf-oleidl-ioleadviseholder-unadvise">IOleAdviseHolder::Unadvise</a> method to delete the advisory connection. The calling object is responsible for calling both <a href="https://docs.microsoft.com/windows/desktop/api/unknwn/nf-unknwn-iunknown-addref">IUnknown::AddRef</a> and <a href="https://docs.microsoft.com/windows/desktop/api/unknwn/nf-unknwn-iunknown-release">IUnknown::Release</a> on this pointer.</param>
			/// <returns>
			/// <para>This method returns S_OK on success. Other possible return values include the following. </para>
			/// <para>This doc was truncated.</para>
			/// </returns>
			/// <remarks>
			/// <para>Containers, object handlers, and link objects all create advise sinks to receive notification of changes in compound-document objects of interest, such as embedded or linked objects. OLE objects of interest to these objects must implement the <a href="https://docs.microsoft.com/windows/desktop/api/oleidl/nn-oleidl-ioleobject">IOleObject</a> interface, which includes several advisory methods, including <a href="https://docs.microsoft.com/windows/desktop/api/oleidl/nf-oleidl-ioleobject-advise">IOleObject::Advise</a>. A call to this method must set up an advisory connection with any advise sink that calls it, and maintain each connection until it is closed. It must be able to handle more than one advisory connection at a time. <b>IOleAdviseHolder::Advise</b> is intended to be used to simplify the implementation of <a href="https://docs.microsoft.com/windows/desktop/api/oleidl/nf-oleidl-ioleobject-advise">IOleObject::Advise</a>. You can get a pointer to the OLE implementation of IOleAdviseHolder by calling <a href="https://docs.microsoft.com/windows/desktop/api/ole2/nf-ole2-createoleadviseholder">CreateOleAdviseHolder</a>, and then, to implement <b>IOleObject::Advise</b>, just delegate the call to <b>IOleAdviseHolder::Advise</b>. Other <a href="https://docs.microsoft.com/windows/desktop/api/oleidl/nn-oleidl-ioleadviseholder">IOleAdviseHolder</a> methods are intended to implement other <a href="https://docs.microsoft.com/windows/desktop/api/oleidl/nn-oleidl-ioleobject">IOleObject</a> advisory methods. If the attempt to establish an advisory connection is successful, the object receiving the call returns a nonzero value through <i>pdwConnection</i>. If the attempt fails, the object returns a zero. To delete an advisory connection, the object with the advise sink passes this nonzero token back to the object by calling <b>IOleAdviseHolder::Advise</b>.</para>
			/// <para><see href="https://learn.microsoft.com/windows/win32/api/oleidl/nf-oleidl-ioleadviseholder-advise#">Read more on docs.microsoft.com</see>.</para>
			/// </remarks>
			public unsafe winmdroot.Foundation.HRESULT Advise(winmdroot.System.Com.IAdviseSink* pAdvise, uint* pdwConnection)
			{
				return ((delegate *unmanaged [Stdcall]<IOleAdviseHolder*,winmdroot.System.Com.IAdviseSink* ,uint* ,winmdroot.Foundation.HRESULT>)lpVtbl[3])((IOleAdviseHolder*)Unsafe.AsPointer(ref this), pAdvise, pdwConnection);
			}

			[UnmanagedCallersOnly(CallConvs = new []{
typeof(CallConvStdcall)}
)]
			private static winmdroot.Foundation.HRESULT Unadvise(IOleAdviseHolder* pThis, uint dwConnection)
			{
				try
				{
					winmdroot.Foundation.HRESULT __hr = ComHelpers.UnwrapCCW(pThis, out Interface __object);
					if (__hr.Failed)
					{
						return __hr;
					}
					return __object.Unadvise(dwConnection);
				}
				catch (Exception ex)
				{
					return (winmdroot.Foundation.HRESULT)ex.HResult;
				}
			}

			/// <summary>Deletes a previously established advisory connection. (IOleAdviseHolder.Unadvise)</summary>
			/// <param name="dwConnection">The value previously returned by <a href="https://docs.microsoft.com/windows/desktop/api/oleidl/nf-oleidl-ioleadviseholder-advise">IOleAdviseHolder::Advise</a> in <i>pdwConnection</i>.</param>
			/// <returns>
			/// <para>This method returns S_OK on success. Other possible return values include the following. </para>
			/// <para>This doc was truncated.</para>
			/// </returns>
			/// <remarks>
			/// <para><b>IOleAdviseHolder::Unadvise</b> is intended to be used to implement <a href="https://docs.microsoft.com/windows/desktop/api/oleidl/nf-oleidl-ioleobject-unadvise">IOleObject::Unadvise</a> to delete an advisory connection. In general, you would use the OLE advise holder having obtained a pointer through a call to <a href="https://docs.microsoft.com/windows/desktop/api/ole2/nf-ole2-createoleadviseholder">CreateOleAdviseHolder</a>. Typically, containers call this method at shutdown or when an object is deleted. In certain cases, containers could call this method on objects that are running but not currently visible, as a way of reducing the overhead of maintaining multiple advisory connections.</para>
			/// <para><see href="https://learn.microsoft.com/windows/win32/api/oleidl/nf-oleidl-ioleadviseholder-unadvise#">Read more on docs.microsoft.com</see>.</para>
			/// </remarks>
			public winmdroot.Foundation.HRESULT Unadvise(uint dwConnection)
			{
				return ((delegate *unmanaged [Stdcall]<IOleAdviseHolder*,uint ,winmdroot.Foundation.HRESULT>)lpVtbl[4])((IOleAdviseHolder*)Unsafe.AsPointer(ref this), dwConnection);
			}

			[UnmanagedCallersOnly(CallConvs = new []{
typeof(CallConvStdcall)}
)]
			private static winmdroot.Foundation.HRESULT EnumAdvise(IOleAdviseHolder* pThis, winmdroot.System.Com.IEnumSTATDATA** ppenumAdvise)
			{
				try
				{
					winmdroot.Foundation.HRESULT __hr = ComHelpers.UnwrapCCW(pThis, out Interface __object);
					if (__hr.Failed)
					{
						return __hr;
					}
					return __object.EnumAdvise(ppenumAdvise);
				}
				catch (Exception ex)
				{
					return (winmdroot.Foundation.HRESULT)ex.HResult;
				}
			}

			/// <summary>Creates an enumerator that can be used to enumerate the advisory connections currently established for an object.</summary>
			/// <param name="ppenumAdvise">A pointer to an <a href="https://docs.microsoft.com/windows/desktop/api/objidl/nn-objidl-ienumstatdata">IEnumSTATDATA</a> pointer variable that receives the interface pointer to the new enumerator. If this parameter is <b>NULL</b>, there are presently no advisory connections on the object, or an error occurred. The advise holder is responsible for incrementing the reference count on the <b>IEnumSTATDATA</b> pointer this method supplies. It is the caller's responsibility to call <a href="https://docs.microsoft.com/windows/desktop/api/unknwn/nf-unknwn-iunknown-release">IUnknown::Release</a> when it is finished with the pointer.</param>
			/// <returns>
			/// <para>This method returns S_OK on success. Other possible return values include the following. </para>
			/// <para>This doc was truncated.</para>
			/// </returns>
			/// <remarks>
			/// <para><b>IOleAdviseHolder::EnumAdvise</b> creates an enumerator that can be used to enumerate an object's established advisory connections. The method supplies a pointer to the <a href="https://docs.microsoft.com/windows/desktop/api/objidl/nn-objidl-ienumstatdata">IEnumSTATDATA</a> interface on this enumerator. Advisory connection information for each connection is stored in the <a href="https://docs.microsoft.com/windows/desktop/api/objidl/ns-objidl-statdata">STATDATA</a> structure, and the enumerator must be able to enumerate these structures. For this method, the only relevant structure members are <b>pAdvise</b> and <b>dwConnection</b>. Other members contain data advisory information. When you call the enumeration methods, and while an enumeration is in progress, the effect of registering or revoking advisory connections on what is to be enumerated is undefined.</para>
			/// <para><see href="https://learn.microsoft.com/windows/win32/api/oleidl/nf-oleidl-ioleadviseholder-enumadvise#">Read more on docs.microsoft.com</see>.</para>
			/// </remarks>
			public unsafe void EnumAdvise(winmdroot.System.Com.IEnumSTATDATA** ppenumAdvise)
			{
				((delegate *unmanaged [Stdcall]<IOleAdviseHolder*,winmdroot.System.Com.IEnumSTATDATA** ,winmdroot.Foundation.HRESULT>)lpVtbl[5])((IOleAdviseHolder*)Unsafe.AsPointer(ref this), ppenumAdvise).ThrowOnFailure();
			}

			[UnmanagedCallersOnly(CallConvs = new []{
typeof(CallConvStdcall)}
)]
			private static winmdroot.Foundation.HRESULT SendOnRename(IOleAdviseHolder* pThis, winmdroot.System.Com.IMoniker* pmk)
			{
				try
				{
					winmdroot.Foundation.HRESULT __hr = ComHelpers.UnwrapCCW(pThis, out Interface __object);
					if (__hr.Failed)
					{
						return __hr;
					}
					return __object.SendOnRename(pmk);
				}
				catch (Exception ex)
				{
					return (winmdroot.Foundation.HRESULT)ex.HResult;
				}
			}

			/// <summary>Sends notification to all advisory sinks currently registered with the advise holder that the name of object has changed.</summary>
			/// <param name="pmk">A pointer to the new full moniker of the object.</param>
			/// <returns>This method returns S_OK if advise sinks were sent <a href="https://docs.microsoft.com/windows/desktop/api/objidl/nf-objidl-iadvisesink-onrename">IAdviseSink::OnRename</a> notifications.</returns>
			/// <remarks><b>SendOnRename</b> calls <a href="https://docs.microsoft.com/windows/desktop/api/objidl/nf-objidl-iadvisesink-onrename">IAdviseSink::OnRename</a> to advise the calling object, which must have already established an advisory connection, that the object has a new moniker. If you are using the OLE advise holder (having obtained a pointer through a call to <a href="https://docs.microsoft.com/windows/desktop/api/ole2/nf-ole2-createoleadviseholder">CreateOleAdviseHolder</a>), you can call <b>SendOnRename</b> in the implementation of <a href="https://docs.microsoft.com/windows/desktop/api/oleidl/nf-oleidl-ioleobject-setmoniker">IOleObject::SetMoniker</a>, when you have determined that the operation is successful.</remarks>
			public unsafe void SendOnRename(winmdroot.System.Com.IMoniker* pmk)
			{
				((delegate *unmanaged [Stdcall]<IOleAdviseHolder*,winmdroot.System.Com.IMoniker* ,winmdroot.Foundation.HRESULT>)lpVtbl[6])((IOleAdviseHolder*)Unsafe.AsPointer(ref this), pmk).ThrowOnFailure();
			}

			[UnmanagedCallersOnly(CallConvs = new []{
typeof(CallConvStdcall)}
)]
			private static winmdroot.Foundation.HRESULT SendOnSave(IOleAdviseHolder* pThis)
			{
				try
				{
					winmdroot.Foundation.HRESULT __hr = ComHelpers.UnwrapCCW(pThis, out Interface __object);
					if (__hr.Failed)
					{
						return __hr;
					}
					return __object.SendOnSave();
				}
				catch (Exception ex)
				{
					return (winmdroot.Foundation.HRESULT)ex.HResult;
				}
			}

			/// <summary>Sends notification to all advisory sinks currently registered with the advise holder that the object has been saved.</summary>
			/// <returns>This method returns S_OK if advise sinks were sent <a href="https://docs.microsoft.com/windows/desktop/api/objidl/nf-objidl-iadvisesink-onsave">IAdviseSink::OnSave</a> notifications.</returns>
			/// <remarks>
			/// <para><b>SendOnSave</b> calls <a href="https://docs.microsoft.com/windows/desktop/api/objidl/nf-objidl-iadvisesink-onsave">IAdviseSink::OnSave</a> to advise the calling object (client), which must have already established an advisory connection, that the object has been saved. If you are using the OLE advise holder (having obtained a pointer through a call to <a href="https://docs.microsoft.com/windows/desktop/api/ole2/nf-ole2-createoleadviseholder">CreateOleAdviseHolder</a>), you can call <b>SendOnSave</b> whenever you save the object the advise holder is associated with. To take the object from the running state to the loaded state, the client calls <a href="https://docs.microsoft.com/windows/desktop/api/oleidl/nf-oleidl-ioleobject-close">IOleObject::Close</a>. Within that implementation, if the user wants to save the object to persistent storage, the object calls <a href="https://docs.microsoft.com/windows/desktop/api/oleidl/nf-oleidl-ioleclientsite-saveobject">IOleClientSite::SaveObject</a>, followed by the call to <b>SendOnSave</b>.</para>
			/// <para><see href="https://learn.microsoft.com/windows/win32/api/oleidl/nf-oleidl-ioleadviseholder-sendonsave#">Read more on docs.microsoft.com</see>.</para>
			/// </remarks>
			public winmdroot.Foundation.HRESULT SendOnSave()
			{
				return ((delegate *unmanaged [Stdcall]<IOleAdviseHolder*,winmdroot.Foundation.HRESULT>)lpVtbl[7])((IOleAdviseHolder*)Unsafe.AsPointer(ref this));
			}

			[UnmanagedCallersOnly(CallConvs = new []{
typeof(CallConvStdcall)}
)]
			private static winmdroot.Foundation.HRESULT SendOnClose(IOleAdviseHolder* pThis)
			{
				try
				{
					winmdroot.Foundation.HRESULT __hr = ComHelpers.UnwrapCCW(pThis, out Interface __object);
					if (__hr.Failed)
					{
						return __hr;
					}
					return __object.SendOnClose();
				}
				catch (Exception ex)
				{
					return (winmdroot.Foundation.HRESULT)ex.HResult;
				}
			}

			/// <summary>Sends notification to all advisory sinks currently registered with the advise holder that the object has closed.</summary>
			/// <returns>This method returns S_OK if advise sinks were notified of the close operation through a call to the <a href="https://docs.microsoft.com/windows/desktop/api/objidl/nf-objidl-iadvisesink-onclose">IAdviseSink::OnClose</a> method.</returns>
			/// <remarks><b>SendOnClose</b> must call <a href="https://docs.microsoft.com/windows/desktop/api/objidl/nf-objidl-iadvisesink-onclose">IAdviseSink::OnClose</a> on all advise sinks that have a valid advisory connection with the object, whenever the object goes from the running state to the loaded state. This occurs through a call to <a href="https://docs.microsoft.com/windows/desktop/api/oleidl/nf-oleidl-ioleobject-close">IOleObject::Close</a>, so you can call <b>SendOnClose</b> when you determine that a Close operation has been successful.</remarks>
			public winmdroot.Foundation.HRESULT SendOnClose()
			{
				return ((delegate *unmanaged [Stdcall]<IOleAdviseHolder*,winmdroot.Foundation.HRESULT>)lpVtbl[8])((IOleAdviseHolder*)Unsafe.AsPointer(ref this));
			}

			internal unsafe global::Windows.Win32.Foundation.HRESULT QueryInterface<T>(out T* ppv)
where T : unmanaged

			{
				var hr = this.QueryInterface(typeof(T).GUID, out void* pv);
				if (hr.Succeeded)

				{
					ppv = (T*)pv;
				}
				else

				{
					ppv = null;
				}

				return hr;
			}

			internal struct Vtbl
			{
				internal delegate *unmanaged [Stdcall]<IOleAdviseHolder*,global::System.Guid* ,void** ,winmdroot.Foundation.HRESULT> QueryInterface_1;

				internal delegate *unmanaged [Stdcall]<IOleAdviseHolder*,uint> AddRef_2;

				internal delegate *unmanaged [Stdcall]<IOleAdviseHolder*,uint> Release_3;

				internal delegate *unmanaged [Stdcall]<IOleAdviseHolder*,winmdroot.System.Com.IAdviseSink* ,uint* ,winmdroot.Foundation.HRESULT> Advise_4;

				internal delegate *unmanaged [Stdcall]<IOleAdviseHolder*,uint ,winmdroot.Foundation.HRESULT> Unadvise_5;

				internal delegate *unmanaged [Stdcall]<IOleAdviseHolder*,winmdroot.System.Com.IEnumSTATDATA** ,winmdroot.Foundation.HRESULT> EnumAdvise_6;

				internal delegate *unmanaged [Stdcall]<IOleAdviseHolder*,winmdroot.System.Com.IMoniker* ,winmdroot.Foundation.HRESULT> SendOnRename_7;

				internal delegate *unmanaged [Stdcall]<IOleAdviseHolder*,winmdroot.Foundation.HRESULT> SendOnSave_8;

				internal delegate *unmanaged [Stdcall]<IOleAdviseHolder*,winmdroot.Foundation.HRESULT> SendOnClose_9;
			} 
			public static void PopulateVTable(Vtbl* vtable)
			{
				vtable->Advise_4 = &Advise;
				vtable->Unadvise_5 = &Unadvise;
				vtable->EnumAdvise_6 = &EnumAdvise;
				vtable->SendOnRename_7 = &SendOnRename;
				vtable->SendOnSave_8 = &SendOnSave;
				vtable->SendOnClose_9 = &SendOnClose;
			}

			private void** lpVtbl;

			/// <summary>The IID guid for this interface.</summary>
			/// <value>{00000111-0000-0000-c000-000000000046}</value>
			internal static readonly Guid IID_Guid = new Guid(0x00000111, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46);

			static ref readonly Guid IComIID.Guid			{
								[MethodImpl(MethodImplOptions.AggressiveInlining)]
get
				{
					ReadOnlySpan<byte> data = new byte[]					{
0x11,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46					};
					return ref Unsafe.As<byte,Guid>(ref MemoryMarshal.GetReference(data));
				}
			}
			[Guid("00000111-0000-0000-C000-000000000046"),InterfaceType(ComInterfaceType.InterfaceIsIUnknown),ComImport()]
			[SupportedOSPlatform("windows5.0")]
			internal interface Interface
			{
				[PreserveSig()]
				unsafe winmdroot.Foundation.HRESULT Advise(winmdroot.System.Com.IAdviseSink* pAdvise, uint* pdwConnection);

								[PreserveSig()]
winmdroot.Foundation.HRESULT Unadvise(uint dwConnection);

				[PreserveSig()]
				unsafe winmdroot.Foundation.HRESULT EnumAdvise(winmdroot.System.Com.IEnumSTATDATA** ppenumAdvise);

				[PreserveSig()]
				unsafe winmdroot.Foundation.HRESULT SendOnRename(winmdroot.System.Com.IMoniker* pmk);

								[PreserveSig()]
winmdroot.Foundation.HRESULT SendOnSave();

								[PreserveSig()]
winmdroot.Foundation.HRESULT SendOnClose();
			}
		}
	}
}