// <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 ComInterfaceDispatch = System.Runtime.InteropServices.ComWrappers.ComInterfaceDispatch;
using Marshal = System.Runtime.InteropServices.Marshal;

namespace CPF.Windows.ComWrapper
{
    [System.Runtime.Versioning.SupportedOSPlatform("windows")]
    unsafe partial class IFileDialogProxy
    {
        [System.Runtime.InteropServices.UnmanagedCallersOnly]
        public static uint Show(System.IntPtr thisPtr, global::System.IntPtr hwndOwner)
        {
            try
            {
                var inst = ComInterfaceDispatch.GetInstance<IFileDialog>((ComInterfaceDispatch*)thisPtr);
                return (uint)inst.Show(hwndOwner);
            }
            catch (System.Exception __e)
            {
                return (uint)__e.HResult;
            }
        }
        [System.Runtime.InteropServices.UnmanagedCallersOnly]
        public static int SetFileTypes(System.IntPtr thisPtr, uint cFileTypes, COMDLG_FILTERSPEC_native* rgFilterSpec, uint* retVal)
        {
            try
            {
                var inst = ComInterfaceDispatch.GetInstance<IFileDialog>((ComInterfaceDispatch*)thisPtr);
                var local_1_length = 1;
                var local_1 = new COMDLG_FILTERSPEC[local_1_length];
                for (int local_1_cnt = 0; local_1_cnt < local_1_length; local_1_cnt++)
                {
                    var arrayItem = rgFilterSpec[local_1_cnt];
                    local_1[local_1_cnt] = new COMDLG_FILTERSPEC { pszName = Marshal.PtrToStringUni(arrayItem.pszName), pszSpec = Marshal.PtrToStringUni(arrayItem.pszSpec) };
                }

                *retVal = inst.SetFileTypes(cFileTypes, local_1);
            }
            catch (System.Exception __e)
            {
                return __e.HResult;
            }

            return 0; // S_OK;
        }
        [System.Runtime.InteropServices.UnmanagedCallersOnly]
        public static int SetFileTypeIndex(System.IntPtr thisPtr, uint iFileType, uint* retVal)
        {
            try
            {
                var inst = ComInterfaceDispatch.GetInstance<IFileDialog>((ComInterfaceDispatch*)thisPtr);
                *retVal = inst.SetFileTypeIndex(iFileType);
            }
            catch (System.Exception __e)
            {
                return __e.HResult;
            }

            return 0; // S_OK;
        }
        [System.Runtime.InteropServices.UnmanagedCallersOnly]
        public static int GetFileTypeIndex(System.IntPtr thisPtr, uint* piFileType, uint* retVal)
        {
            try
            {
                var inst = ComInterfaceDispatch.GetInstance<IFileDialog>((ComInterfaceDispatch*)thisPtr);
                *retVal = inst.GetFileTypeIndex(out *piFileType);
            }
            catch (System.Exception __e)
            {
                return __e.HResult;
            }

            return 0; // S_OK;
        }
        [System.Runtime.InteropServices.UnmanagedCallersOnly]
        public static int Advise(System.IntPtr thisPtr, global::System.IntPtr pfde, uint* pdwCookie, uint* retVal)
        {
            try
            {
                var inst = ComInterfaceDispatch.GetInstance<IFileDialog>((ComInterfaceDispatch*)thisPtr);
                *retVal = inst.Advise(pfde, out *pdwCookie);
            }
            catch (System.Exception __e)
            {
                return __e.HResult;
            }

            return 0; // S_OK;
        }
        [System.Runtime.InteropServices.UnmanagedCallersOnly]
        public static int Unadvise(System.IntPtr thisPtr, uint dwCookie, uint* retVal)
        {
            try
            {
                var inst = ComInterfaceDispatch.GetInstance<IFileDialog>((ComInterfaceDispatch*)thisPtr);
                *retVal = inst.Unadvise(dwCookie);
            }
            catch (System.Exception __e)
            {
                return __e.HResult;
            }

            return 0; // S_OK;
        }
        [System.Runtime.InteropServices.UnmanagedCallersOnly]
        public static int SetOptions(System.IntPtr thisPtr, uint fos, uint* retVal)
        {
            try
            {
                var inst = ComInterfaceDispatch.GetInstance<IFileDialog>((ComInterfaceDispatch*)thisPtr);
                *retVal = inst.SetOptions(fos);
            }
            catch (System.Exception __e)
            {
                return __e.HResult;
            }

            return 0; // S_OK;
        }
        [System.Runtime.InteropServices.UnmanagedCallersOnly]
        public static int GetOptions(System.IntPtr thisPtr, uint* fos, uint* retVal)
        {
            try
            {
                var inst = ComInterfaceDispatch.GetInstance<IFileDialog>((ComInterfaceDispatch*)thisPtr);
                *retVal = inst.GetOptions(out *fos);
            }
            catch (System.Exception __e)
            {
                return __e.HResult;
            }

            return 0; // S_OK;
        }
        [System.Runtime.InteropServices.UnmanagedCallersOnly]
        public static int SetDefaultFolder(System.IntPtr thisPtr, System.IntPtr psi)
        {
            try
            {
                var inst = ComInterfaceDispatch.GetInstance<IFileDialog>((ComInterfaceDispatch*)thisPtr);
                var local_0 = psi == System.IntPtr.Zero ? null : (IShellItem)Marshal.GetObjectForIUnknown(psi);
                inst.SetDefaultFolder(local_0);
            }
            catch (System.Exception __e)
            {
                return __e.HResult;
            }

            return 0; // S_OK;
        }
        [System.Runtime.InteropServices.UnmanagedCallersOnly]
        public static int SetFolder(System.IntPtr thisPtr, System.IntPtr psi, uint* retVal)
        {
            try
            {
                var inst = ComInterfaceDispatch.GetInstance<IFileDialog>((ComInterfaceDispatch*)thisPtr);
                var local_0 = psi == System.IntPtr.Zero ? null : (IShellItem)Marshal.GetObjectForIUnknown(psi);
                *retVal = inst.SetFolder(local_0);
            }
            catch (System.Exception __e)
            {
                return __e.HResult;
            }

            return 0; // S_OK;
        }
        [System.Runtime.InteropServices.UnmanagedCallersOnly]
        public static int GetFolder(System.IntPtr thisPtr, System.IntPtr* ppsi, uint* retVal)
        {
            try
            {
                var inst = ComInterfaceDispatch.GetInstance<IFileDialog>((ComInterfaceDispatch*)thisPtr);
                IShellItem local_0;
                *retVal = inst.GetFolder(out local_0);
                *ppsi = local_0 == null ? System.IntPtr.Zero : Marshal.GetIUnknownForObject(local_0);
            }
            catch (System.Exception __e)
            {
                return __e.HResult;
            }

            return 0; // S_OK;
        }
        [System.Runtime.InteropServices.UnmanagedCallersOnly]
        public static int GetCurrentSelection(System.IntPtr thisPtr, System.IntPtr* ppsi, uint* retVal)
        {
            try
            {
                var inst = ComInterfaceDispatch.GetInstance<IFileDialog>((ComInterfaceDispatch*)thisPtr);
                IShellItem local_0;
                *retVal = inst.GetCurrentSelection(out local_0);
                *ppsi = local_0 == null ? System.IntPtr.Zero : Marshal.GetIUnknownForObject(local_0);
            }
            catch (System.Exception __e)
            {
                return __e.HResult;
            }

            return 0; // S_OK;
        }
        [System.Runtime.InteropServices.UnmanagedCallersOnly]
        public static int SetFileName(System.IntPtr thisPtr, System.IntPtr pszName, uint* retVal)
        {
            try
            {
                var inst = ComInterfaceDispatch.GetInstance<IFileDialog>((ComInterfaceDispatch*)thisPtr);
                var local_0 = Marshal.PtrToStringUni(pszName);
                *retVal = inst.SetFileName(local_0);
            }
            catch (System.Exception __e)
            {
                return __e.HResult;
            }

            return 0; // S_OK;
        }
        [System.Runtime.InteropServices.UnmanagedCallersOnly]
        public static int GetFileName(System.IntPtr thisPtr, System.IntPtr* pszName, uint* retVal)
        {
            try
            {
                var inst = ComInterfaceDispatch.GetInstance<IFileDialog>((ComInterfaceDispatch*)thisPtr);
                string local_0;
                *retVal = inst.GetFileName(out local_0);
                *pszName = local_0 == null ? System.IntPtr.Zero : Marshal.StringToCoTaskMemUni(local_0);
            }
            catch (System.Exception __e)
            {
                return __e.HResult;
            }

            return 0; // S_OK;
        }
        [System.Runtime.InteropServices.UnmanagedCallersOnly]
        public static int SetTitle(System.IntPtr thisPtr, System.IntPtr pszTitle, uint* retVal)
        {
            try
            {
                var inst = ComInterfaceDispatch.GetInstance<IFileDialog>((ComInterfaceDispatch*)thisPtr);
                var local_0 = Marshal.PtrToStringUni(pszTitle);
                *retVal = inst.SetTitle(local_0);
            }
            catch (System.Exception __e)
            {
                return __e.HResult;
            }

            return 0; // S_OK;
        }
        [System.Runtime.InteropServices.UnmanagedCallersOnly]
        public static int SetOkButtonLabel(System.IntPtr thisPtr, System.IntPtr pszText, uint* retVal)
        {
            try
            {
                var inst = ComInterfaceDispatch.GetInstance<IFileDialog>((ComInterfaceDispatch*)thisPtr);
                var local_0 = Marshal.PtrToStringUni(pszText);
                *retVal = inst.SetOkButtonLabel(local_0);
            }
            catch (System.Exception __e)
            {
                return __e.HResult;
            }

            return 0; // S_OK;
        }
        [System.Runtime.InteropServices.UnmanagedCallersOnly]
        public static int SetFileNameLabel(System.IntPtr thisPtr, System.IntPtr pszLabel, uint* retVal)
        {
            try
            {
                var inst = ComInterfaceDispatch.GetInstance<IFileDialog>((ComInterfaceDispatch*)thisPtr);
                var local_0 = Marshal.PtrToStringUni(pszLabel);
                *retVal = inst.SetFileNameLabel(local_0);
            }
            catch (System.Exception __e)
            {
                return __e.HResult;
            }

            return 0; // S_OK;
        }
        [System.Runtime.InteropServices.UnmanagedCallersOnly]
        public static int GetResult(System.IntPtr thisPtr, System.IntPtr* ppsi, uint* retVal)
        {
            try
            {
                var inst = ComInterfaceDispatch.GetInstance<IFileDialog>((ComInterfaceDispatch*)thisPtr);
                IShellItem local_0;
                *retVal = inst.GetResult(out local_0);
                *ppsi = local_0 == null ? System.IntPtr.Zero : Marshal.GetIUnknownForObject(local_0);
            }
            catch (System.Exception __e)
            {
                return __e.HResult;
            }

            return 0; // S_OK;
        }
        [System.Runtime.InteropServices.UnmanagedCallersOnly]
        public static int AddPlace(System.IntPtr thisPtr, System.IntPtr psi, uint fdap, uint* retVal)
        {
            try
            {
                var inst = ComInterfaceDispatch.GetInstance<IFileDialog>((ComInterfaceDispatch*)thisPtr);
                var local_0 = psi == System.IntPtr.Zero ? null : (IShellItem)Marshal.GetObjectForIUnknown(psi);
                *retVal = inst.AddPlace(local_0, fdap);
            }
            catch (System.Exception __e)
            {
                return __e.HResult;
            }

            return 0; // S_OK;
        }
        [System.Runtime.InteropServices.UnmanagedCallersOnly]
        public static int SetDefaultExtension(System.IntPtr thisPtr, System.IntPtr pszDefaultExtension, uint* retVal)
        {
            try
            {
                var inst = ComInterfaceDispatch.GetInstance<IFileDialog>((ComInterfaceDispatch*)thisPtr);
                var local_0 = Marshal.PtrToStringUni(pszDefaultExtension);
                *retVal = inst.SetDefaultExtension(local_0);
            }
            catch (System.Exception __e)
            {
                return __e.HResult;
            }

            return 0; // S_OK;
        }
        [System.Runtime.InteropServices.UnmanagedCallersOnly]
        public static int Close(System.IntPtr thisPtr, uint hr, uint* retVal)
        {
            try
            {
                var inst = ComInterfaceDispatch.GetInstance<IFileDialog>((ComInterfaceDispatch*)thisPtr);
                *retVal = inst.Close(hr);
            }
            catch (System.Exception __e)
            {
                return __e.HResult;
            }

            return 0; // S_OK;
        }
        [System.Runtime.InteropServices.UnmanagedCallersOnly]
        public static int SetClientGuid(System.IntPtr thisPtr, global::System.Guid* guid, uint* retVal)
        {
            try
            {
                var inst = ComInterfaceDispatch.GetInstance<IFileDialog>((ComInterfaceDispatch*)thisPtr);
                *retVal = inst.SetClientGuid(ref *guid);
            }
            catch (System.Exception __e)
            {
                return __e.HResult;
            }

            return 0; // S_OK;
        }
        [System.Runtime.InteropServices.UnmanagedCallersOnly]
        public static int ClearClientData(System.IntPtr thisPtr, uint* retVal)
        {
            try
            {
                var inst = ComInterfaceDispatch.GetInstance<IFileDialog>((ComInterfaceDispatch*)thisPtr);
                *retVal = inst.ClearClientData();
            }
            catch (System.Exception __e)
            {
                return __e.HResult;
            }

            return 0; // S_OK;
        }
        [System.Runtime.InteropServices.UnmanagedCallersOnly]
        public static int SetFilter(System.IntPtr thisPtr, global::System.IntPtr pFilter, uint* retVal)
        {
            try
            {
                var inst = ComInterfaceDispatch.GetInstance<IFileDialog>((ComInterfaceDispatch*)thisPtr);
                *retVal = inst.SetFilter(pFilter);
            }
            catch (System.Exception __e)
            {
                return __e.HResult;
            }

            return 0; // S_OK;
        }
    }
}