using static Vanara.PInvoke.ShlwApi; namespace Vanara.PInvoke; public static partial class Shell32 { /// Defines shortcut menu restrictions used by IDefaultFolderMenuInitialize::GetMenuRestrictions and IDefaultFolderMenuInitialize::SetMenuRestrictions. // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/ne-shobjidl_core-default_folder_menu_restrictions typedef enum // DEFAULT_FOLDER_MENU_RESTRICTIONS { DFMR_DEFAULT, DFMR_NO_STATIC_VERBS, DFMR_STATIC_VERBS_ONLY, DFMR_NO_RESOURCE_VERBS, // DFMR_OPTIN_HANDLERS_ONLY, DFMR_RESOURCE_AND_FOLDER_VERBS_ONLY, DFMR_USE_SPECIFIED_HANDLERS, DFMR_USE_SPECIFIED_VERBS, // DFMR_NO_ASYNC_VERBS, DFMR_NO_NATIVECPU_VERBS } ; [PInvokeData("shobjidl_core.h", MSDNShortId = "NE:shobjidl_core.DEFAULT_FOLDER_MENU_RESTRICTIONS")] [Flags] public enum DEFAULT_FOLDER_MENU_RESTRICTIONS { /// No restrictions. DFMR_DEFAULT = 0x0000, /// Don't use the handler for static verbs. DFMR_NO_STATIC_VERBS = 0x0008, /// Static verbs only. No dynamic IContextMenu verbs allowed. DFMR_STATIC_VERBS_ONLY = 0x0010, /// Don't add verbs for cut, copy, paste, link, delete, rename, or properties. DFMR_NO_RESOURCE_VERBS = 0x0020, /// Only load opt-in handlers that have the registry value "ContextMenuOptIn" under HKCR\CLSID<handler clsid> DFMR_OPTIN_HANDLERS_ONLY = 0x0040, /// /// Only load resource verbs (cut, copy, paste, link, delete, rename, and properties) and folder verbs added by IContextMenuCB. /// DFMR_RESOURCE_AND_FOLDER_VERBS_ONLY = 0x0080, /// Use handlers with CLSID values that were added through IDefaultFolderMenuInitialize::SetHandlerClsid DFMR_USE_SPECIFIED_HANDLERS = 0x0100, /// Only load handlers that support the specified verbs. DFMR_USE_SPECIFIED_VERBS = 0x0200, /// Ignore async verbs. DFMR_NO_ASYNC_VERBS = 0x0400, /// Ignore verbs that are registered for the native CPU architecture. DFMR_NO_NATIVECPU_VERBS = 0x0800, } /// /// /// Provides methods used to get and set shortcut menu information. This information is the same as that provided to through the structure. /// /// Note Do not use this method to reinitialize a shortcut menu; use IShellExtInit::Initialize instead. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nn-shobjidl_core-idefaultfoldermenuinitialize [PInvokeData("shobjidl_core.h", MSDNShortId = "NN:shobjidl_core.IDefaultFolderMenuInitialize")] [ComImport, Guid("7690aa79-f8fc-4615-a327-36f7d18f5d91"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IDefaultFolderMenuInitialize { /// Sets context menu info for the IDefaultFolderMenuInitialize object. /// A handle to the shortcut menu. /// /// Type: IContextMenuCB* /// The address of the object that defines the callback for the shortcut menu. /// /// /// Type: PCIDLIST_ABSOLUTE /// /// The address of an item identifier list that specifies the folder of the items. If NULL, this is computed from the psf parameter. /// /// /// /// Type: IShellFolder* /// The folder of the items. /// /// /// Type: UINT /// The count of items in the apidl parameter. /// /// /// Type: PCUITEMID_CHILD_ARRAY /// A pointer to an array of PIDL structures, each of which is an item to be operated on. /// /// /// Type: IUnknown* /// The address of an IQueryAssociations object that specifies where to load extensions from. /// /// /// Type: UINT /// The count of items in the aKeys parameter. May be zero. /// /// /// Type: const HKEY* /// Specifies where to load extensions from. /// /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. // https://docs.microsoft.com/ja-jp/windows/win32/api/shobjidl_core/nf-shobjidl_core-idefaultfoldermenuinitialize-initialize // HRESULT Initialize( HWND hwnd, IContextMenuCB *pcmcb, PCIDLIST_ABSOLUTE pidlFolder, IShellFolder *psf, UINT cidl, // PCUITEMID_CHILD_ARRAY apidl, IUnknown *punkAssociation, UINT cKeys, const HKEY *aKeys ); [PreserveSig] HRESULT Initialize(HWND hwnd, [In, Optional] IContextMenuCB? pcmcb, [In, Optional] PIDL pidlFolder, [In, Optional] IShellFolder? psf, uint cidl, [In, MarshalAs(UnmanagedType.LPArray)] IntPtr[] apidl, [In, Optional] IQueryAssociations? punkAssociation, uint cKeys, [In, Optional, MarshalAs(UnmanagedType.LPArray)] HKEY[]? aKeys); /// Sets shortcut menu restrictions for the IDefaultFolderMenuInitialize object. /// /// A bitwise combination of the DEFAULT_FOLDER_MENU_RESTRICTIONS values that specify the restrictions to set. /// /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-idefaultfoldermenuinitialize-setmenurestrictions // HRESULT SetMenuRestrictions( DEFAULT_FOLDER_MENU_RESTRICTIONS dfmrValues ); [PreserveSig] HRESULT SetMenuRestrictions(DEFAULT_FOLDER_MENU_RESTRICTIONS dfmrValues); /// Gets shortcut menu restrictions that are currently set for the IDefaultFolderMenuInitialize object. /// /// A bitwise combination of the DEFAULT_FOLDER_MENU_RESTRICTIONS values that specify the mask of the restrictions to get. /// /// A bitwise combination of the DEFAULT_FOLDER_MENU_RESTRICTIONS values that specify the restrictions. /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-idefaultfoldermenuinitialize-getmenurestrictions // HRESULT GetMenuRestrictions( DEFAULT_FOLDER_MENU_RESTRICTIONS dfmrMask, DEFAULT_FOLDER_MENU_RESTRICTIONS *pdfmrValues ); [PreserveSig] HRESULT GetMenuRestrictions(DEFAULT_FOLDER_MENU_RESTRICTIONS dfmrMask, out DEFAULT_FOLDER_MENU_RESTRICTIONS pdfmrValues); /// Sets the shortcut menu handler for the IDefaultFolderMenuInitialize object. /// /// Type: REFCLSID /// The CLSID for the object defines the shortcut menu handler. /// /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-idefaultfoldermenuinitialize-sethandlerclsid // HRESULT SetHandlerClsid( REFCLSID rclsid ); [PreserveSig] HRESULT SetHandlerClsid(in Guid rclsid); } }