#nullable disable using System.Runtime.InteropServices; // ReSharper disable FieldCanBeMadeReadOnly.Global // ReSharper disable UnusedMember.Global namespace BizHawk.Common { public static class Shell32Imports { public const int BFFM_INITIALIZED = 1; public const int BFFM_SETSELECTIONW = 0x400 + 103; [UnmanagedFunctionPointer(CallingConvention.Winapi)] public delegate int BFFCALLBACK(IntPtr hwnd, uint uMsg, IntPtr lParam, IntPtr lpData); [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] public struct BROWSEINFOW { public IntPtr hwndOwner; public IntPtr pidlRoot; public IntPtr pszDisplayName; [MarshalAs(UnmanagedType.LPWStr)] public string lpszTitle; public FLAGS ulFlags; [MarshalAs(UnmanagedType.FunctionPtr)] public BFFCALLBACK lpfn; public IntPtr lParam; public int iImage; [Flags] public enum FLAGS { /// BIF_RETURNONLYFSDIRS RestrictToFilesystem = 0x0001, /// BIF_DONTGOBELOWDOMAIN RestrictToDomain = 0x0002, /// BIF_RETURNFSANCESTORS RestrictToSubfolders = 0x0008, /// BIF_EDITBOX ShowTextBox = 0x0010, /// BIF_VALIDATE ValidateSelection = 0x0020, /// BIF_NEWDIALOGSTYLE NewDialogStyle = 0x0040, /// BIF_BROWSEFORCOMPUTER BrowseForComputer = 0x1000, /// BIF_BROWSEFORPRINTER BrowseForPrinter = 0x2000, /// BIF_BROWSEINCLUDEFILES BrowseForEverything = 0x4000 } } [DllImport("shell32.dll", CharSet = CharSet.Unicode, ExactSpelling = true)] public static extern IntPtr SHBrowseForFolderW(ref BROWSEINFOW bi); [DllImport("shell32.dll", CharSet = CharSet.Unicode, ExactSpelling = true)] public static extern int SHGetPathFromIDListW(IntPtr pidl, char[] pszPath); [DllImport("shell32.dll", ExactSpelling = true)] public static extern int SHGetSpecialFolderLocation(IntPtr hwndOwner, int nFolder, out IntPtr ppidl); [DllImport("shell32.dll", CharSet = CharSet.Unicode, ExactSpelling = true)] public static extern int SHCreateItemFromParsingName( [In] string pszPath, [In] IntPtr pbc, [In, MarshalAs(UnmanagedType.LPStruct)] Guid riid, out IntPtr ppv); [DllImport("shell32.dll", ExactSpelling = true)] public static extern int SHGetIDListFromObject(IntPtr punk, out IntPtr ppidl); [DllImport("shell32.dll", EntryPoint = "#16")] public static extern IntPtr ILFindLastID(IntPtr pidl); } }