// <auto-generated>
// Code generated by COM Proxy Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
// </auto-generated>
#nullable enable
using System;
using System.Runtime.InteropServices.ComTypes;
using ComInterfaceDispatch = System.Runtime.InteropServices.ComWrappers.ComInterfaceDispatch;
using Marshal = System.Runtime.InteropServices.Marshal;

namespace CPF.Windows.ComWrapper
{
    [System.Runtime.Versioning.SupportedOSPlatform("windows")]
    unsafe partial class IDataObjectProxy
    {
        [System.Runtime.InteropServices.UnmanagedCallersOnly]
        public static int GetData(System.IntPtr thisPtr, FORMATETC* format, STGMEDIUM* medium)
        {
            try
            {
                var inst = ComInterfaceDispatch.GetInstance<IOleDataObject>((ComInterfaceDispatch*)thisPtr);
                inst.GetData(ref *format, out *medium);
            }
            catch (System.Exception __e)
            {
                Console.WriteLine(__e);
                return __e.HResult;
            }

            return 0; // S_OK;
        }
        [System.Runtime.InteropServices.UnmanagedCallersOnly]
        public static int GetDataHere(System.IntPtr thisPtr, FORMATETC* format, STGMEDIUM* medium)
        {
            try
            {
                var inst = ComInterfaceDispatch.GetInstance<IOleDataObject>((ComInterfaceDispatch*)thisPtr);
                inst.GetDataHere(ref *format, ref *medium);
            }
            catch (System.Exception __e)
            {
                Console.WriteLine(__e);
                return __e.HResult;
            }

            return 0; // S_OK;
        }
        [System.Runtime.InteropServices.UnmanagedCallersOnly]
        public static int QueryGetData(System.IntPtr thisPtr, FORMATETC* format)
        {
            try
            {
                var inst = ComInterfaceDispatch.GetInstance<IOleDataObject>((ComInterfaceDispatch*)thisPtr);
                return (int)inst.QueryGetData(ref *format);
            }
            catch (System.Exception __e)
            {
                Console.WriteLine(__e);
                return __e.HResult;
            }
        }
        [System.Runtime.InteropServices.UnmanagedCallersOnly]
        public static int GetCanonicalFormatEtc(System.IntPtr thisPtr, FORMATETC* formatIn, FORMATETC* formatOut)
        {
            try
            {
                var inst = ComInterfaceDispatch.GetInstance<IOleDataObject>((ComInterfaceDispatch*)thisPtr);
                return (int)inst.GetCanonicalFormatEtc(ref *formatIn, out *formatOut);
            }
            catch (System.Exception __e)
            {
                Console.WriteLine(__e);
                return __e.HResult;
            }
        }
        [System.Runtime.InteropServices.UnmanagedCallersOnly]
        public static int SetData(System.IntPtr thisPtr, FORMATETC* formatIn, STGMEDIUM* medium, bool release)
        {
            try
            {
                var inst = ComInterfaceDispatch.GetInstance<IOleDataObject>((ComInterfaceDispatch*)thisPtr);
                inst.SetData(ref *formatIn, ref *medium, release);
            }
            catch (System.Exception __e)
            {
                Console.WriteLine(__e);
                return __e.HResult;
            }

            return 0; // S_OK;
        }
        [System.Runtime.InteropServices.UnmanagedCallersOnly]
        public static int EnumFormatEtc(System.IntPtr thisPtr, int direction, System.IntPtr* retVal)
        {
            try
            {
                var inst = ComInterfaceDispatch.GetInstance<IOleDataObject>((ComInterfaceDispatch*)thisPtr);
                var retValManaged = inst.EnumFormatEtc((global::System.Runtime.InteropServices.ComTypes.DATADIR)direction);
                if (retValManaged != null)
                {
                    var retValLocal = Marshal.GetIUnknownForObject(retValManaged);
                    var targetInterface = new System.Guid("00000103-0000-0000-C000-000000000046");
                    try
                    {
                        var hrResult = Marshal.QueryInterface(retValLocal, ref targetInterface, out *retVal);
                        if (hrResult < 0)
                        {
                            Marshal.ThrowExceptionForHR(hrResult);
                        }
                    }
                    finally
                    {
                        Marshal.Release(retValLocal);
                    }
                }
                else
                {
                    *retVal = System.IntPtr.Zero;
                }
            }
            catch (System.Exception __e)
            {
                Console.WriteLine(__e);
                return __e.HResult;
            }

            return 0; // S_OK;
        }
        [System.Runtime.InteropServices.UnmanagedCallersOnly]
        public static int DAdvise(System.IntPtr thisPtr, FORMATETC* pFormatetc, int advf, System.IntPtr adviseSink, int* connection)
        {
            try
            {
                var inst = ComInterfaceDispatch.GetInstance<IOleDataObject>((ComInterfaceDispatch*)thisPtr);
                var local_2 = adviseSink == System.IntPtr.Zero ? null : (global::System.Runtime.InteropServices.ComTypes.IAdviseSink)Marshal.GetObjectForIUnknown(adviseSink);
                return (int)inst.DAdvise(ref *pFormatetc, (global::System.Runtime.InteropServices.ComTypes.ADVF)advf, local_2, out *connection);
            }
            catch (System.Exception __e)
            {
                Console.WriteLine(__e);
                return __e.HResult;
            }
        }
        [System.Runtime.InteropServices.UnmanagedCallersOnly]
        public static int DUnadvise(System.IntPtr thisPtr, int connection)
        {
            try
            {
                var inst = ComInterfaceDispatch.GetInstance<IOleDataObject>((ComInterfaceDispatch*)thisPtr);
                inst.DUnadvise(connection);
            }
            catch (System.Exception __e)
            {
                Console.WriteLine(__e);
                return __e.HResult;
            }

            return 0; // S_OK;
        }
        [System.Runtime.InteropServices.UnmanagedCallersOnly]
        public static int EnumDAdvise(System.IntPtr thisPtr, System.IntPtr* enumAdvise)
        {
            try
            {
                var inst = ComInterfaceDispatch.GetInstance<IOleDataObject>((ComInterfaceDispatch*)thisPtr);
                global::System.Runtime.InteropServices.ComTypes.IEnumSTATDATA local_0;
                return (int)inst.EnumDAdvise(out local_0);
                //*enumAdvise = local_0 == null ? System.IntPtr.Zero : Marshal.GetIUnknownForObject(local_0);
            }
            catch (System.Exception __e)
            {
                Console.WriteLine(__e);
                return __e.HResult;
            }
        }
    }
}