From 373a969eaab8bf60c0c62ff127687df58a3990f0 Mon Sep 17 00:00:00 2001 From: David Hall Date: Mon, 2 Jul 2018 17:43:17 -0600 Subject: [PATCH] Added interfaces for Shell Namespace Extensions --- PInvoke/Shell32/ShObjIdl.IContextMenu.cs | 445 ++++++++++++++++++++++ PInvoke/Shell32/ShObjIdl.IInitializeWithFile.cs | 20 + PInvoke/Shell32/ShObjIdl.IInitializeWithItem.cs | 18 + PInvoke/Shell32/ShObjIdl.IInitializeWithStream.cs | 19 + PInvoke/Shell32/ShObjIdl.IShellExtInit.cs | 27 ++ 5 files changed, 529 insertions(+) create mode 100644 PInvoke/Shell32/ShObjIdl.IContextMenu.cs create mode 100644 PInvoke/Shell32/ShObjIdl.IInitializeWithFile.cs create mode 100644 PInvoke/Shell32/ShObjIdl.IInitializeWithItem.cs create mode 100644 PInvoke/Shell32/ShObjIdl.IInitializeWithStream.cs create mode 100644 PInvoke/Shell32/ShObjIdl.IShellExtInit.cs diff --git a/PInvoke/Shell32/ShObjIdl.IContextMenu.cs b/PInvoke/Shell32/ShObjIdl.IContextMenu.cs new file mode 100644 index 00000000..837dc083 --- /dev/null +++ b/PInvoke/Shell32/ShObjIdl.IContextMenu.cs @@ -0,0 +1,445 @@ +using System; +using System.Runtime.InteropServices; + +namespace Vanara.PInvoke +{ + public static partial class Shell32 + { + public const string CMDSTR_NEWFOLDER = "NewFolder"; + public const string CMDSTR_OPEN = "Open"; + public const string CMDSTR_PREVIEW = "Preview"; + public const string CMDSTR_PRINT = "Print"; + public const string CMDSTR_RUNAS = "RunAs"; + public const string CMDSTR_VIEWDETAILS = "ViewDetails"; + public const string CMDSTR_VIEWLIST = "ViewList"; + + /// Flag options for the IContextMenu interface. + [Flags] + public enum CMF : uint + { + /// Indicates normal operation. A shortcut menu extension, namespace extension, or drag-and-drop handler can add all menu items. + CMF_NORMAL = 0x00000000, + + /// + /// The user is activating the default action, typically by double-clicking. This flag provides a hint for the shortcut menu extension to add nothing + /// if it does not modify the default item in the menu. A shortcut menu extension or drag-and-drop handler should not add any menu items if this + /// value is specified. A namespace extension should at most add only the default item. + /// + CMF_DEFAULTONLY = 0x00000001, + + /// The shortcut menu is that of a shortcut file (normally, a .lnk file). Shortcut menu handlers should ignore this value. + CMF_VERBSONLY = 0x00000002, + + /// The Windows Explorer tree window is present. + CMF_EXPLORE = 0x00000004, + + /// This flag is set for items displayed in the Send To menu. Shortcut menu handlers should ignore this value. + CMF_NOVERBS = 0x00000008, + + /// + /// The calling application supports renaming of items. A shortcut menu or drag-and-drop handler should ignore this flag. A namespace extension + /// should add a Rename item to the menu if applicable. + /// + CMF_CANRENAME = 0x00000010, + + /// + /// No item in the menu has been set as the default. A drag-and-drop handler should ignore this flag. A namespace extension should not set any of the + /// menu items as the default. + /// + CMF_NODEFAULT = 0x00000020, + + ///0x00000100. The calling application wants extended verbs. Normal verbs are displayed when the user right-clicks an object. To display extended verbs, the user must right-click while pressing the Shift key. + CMF_EXTENDEDVERBS = 0x00000100, + + /// + /// This value is not available. + /// + /// Windows Server 2003 and Windows XP: 0x00000040. A static menu is being constructed. Only the browser should use this flag; all other shortcut + /// menu extensions should ignore it. + /// + /// + CMF_INCLUDESTATIC = 0x00000040, + + /// + /// 0x00000080. The calling application is invoking a shortcut menu on an item in the view (as opposed to the background of the view). + /// Windows Server 2003 and Windows XP: This value is not available. + /// + CMF_ITEMMENU = 0x00000080, + + /// + /// 0x00000200. The calling application intends to invoke verbs that are disabled, such as legacy menus. + /// Windows Server 2003 and Windows XP: This value is not available. + /// + CMF_DISABLEDVERBS = 0x00000200, + + /// + /// 0x00000400. The verb state can be evaluated asynchronously. + /// Windows Server 2008, Windows Vista, Windows Server 2003 and Windows XP: This value is not available. + /// + CMF_ASYNCVERBSTATE = 0x00000400, + + /// + /// 0x00000800. Informs context menu handlers that do not support the invocation of a verb through a canonical verb name to bypass + /// IContextMenu::QueryContextMenu in their implementation. + /// Windows Server 2008, Windows Vista, Windows Server 2003 and Windows XP: This value is not available. + /// + CMF_OPTIMIZEFORINVOKE = 0x00000800, + + /// + /// 0x00001000. Populate submenus synchronously. + /// Windows Server 2008, Windows Vista, Windows Server 2003 and Windows XP: This value is not available. + /// + CMF_SYNCCASCADEMENU = 0x00001000, + + /// + /// 0x00001000. When no verb is explicitly specified, do not use a default verb in its place. + /// Windows Server 2008, Windows Vista, Windows Server 2003 and Windows XP: This value is not available. + /// + CMF_DONOTPICKDEFAULT = 0x00002000, + + /// + /// 0xffff0000. This flag is a bitmask that specifies all bits that should not be used. This is to be used only as a mask. Do not pass this as a + /// parameter value. + /// + CMF_RESERVED = 0xffff0000, + } + + /// Indicate desired behavior and indicate that other fields in the structure are to be used for . + [Flags] + public enum CMIC : uint + { + /// The hIcon member is valid. As of Windows Vista this flag is not used. + CMIC_MASK_ICON = 0x00000010, + + /// The dwHotKey member is valid. + CMIC_MASK_HOTKEY = 0x00000020, + + /// + /// Windows Vista and later. The implementation of IContextMenu::InvokeCommand should be synchronous, not returning before it is complete. Since this + /// is recommended, calling applications that specify this flag cannot guarantee that this request will be honored if they are not familiar with the + /// implementation of the verb that they are invoking. + /// + CMIC_MASK_NOASYNC = 0x00000100, + + /// The system is prevented from displaying user interface elements (for example, error messages) while carrying out a command. + CMIC_MASK_FLAG_NO_UI = 0x00000400, + + /// + /// The shortcut menu handler should use lpVerbW, lpParametersW, lpDirectoryW, and lpTitleW members instead of their ANSI equivalents. Because some + /// shortcut menu handlers may not support Unicode, you should also pass valid ANSI strings in the lpVerb, lpParameters, lpDirectory, and lpTitle members. + /// + CMIC_MASK_UNICODE = 0x00004000, + + /// + /// If a shortcut menu handler needs to create a new process, it will normally create a new console. Setting the CMIC_MASK_NO_CONSOLE flag suppresses + /// the creation of a new console. + /// + CMIC_MASK_NO_CONSOLE = 0x00008000, + + /// Wait for the DDE conversation to terminate before returning. + CMIC_MASK_ASYNCOK = 0x00100000, + + /// Do not perform a zone check. This flag allows ShellExecuteEx to bypass zone checking put into place by IAttachmentExecute. + CMIC_MASK_NOZONECHECKS = 0x00800000, + + /// + /// Indicates that the implementation of IContextMenu::InvokeCommand might want to keep track of the item being invoked for features like the "Recent + /// documents" menu. + /// + CMIC_MASK_FLAG_LOG_USAGE = 0x04000000, + + /// + /// The SHIFT key is pressed. Use this instead of polling the current state of the keyboard that may have changed since the verb was invoked. + /// + CMIC_MASK_SHIFT_DOWN = 0x10000000, + + /// The ptInvoke member is valid. + CMIC_MASK_PTINVOKE = 0x20000000, + + /// + /// The CTRL key is pressed. Use this instead of polling the current state of the keyboard that may have changed since the verb was invoked. + /// + CMIC_MASK_CONTROL_DOWN = 0x40000000, + } + + /// Flags specifying the information to return. + public enum GCS : uint + { + /// Sets pszName to an ANSI string containing the language-independent command name for the menu item. + GCS_VERBA = 0x00000000, + /// Sets pszName to an ANSI string containing the help text for the command. + GCS_HELPTEXTA = 0x00000001, + /// Returns S_OK if the menu item exists, or S_FALSE otherwise. + GCS_VALIDATEA = 0x00000002, + /// Sets pszName to a Unicode string containing the language-independent command name for the menu item. + GCS_VERBW = 0x00000004, + /// Sets pszName to a Unicode string containing the help text for the command. + GCS_HELPTEXTW = 0x00000005, + /// Returns S_OK if the menu item exists, or S_FALSE otherwise. + GCS_VALIDATEW = 0x00000006, + /// Sets pszName to a Unicode string containing the icon string for the command. + GCS_VERBICONW = 0x00000014, + /// For Unicode bit testing. + GCS_UNICODE = 0x00000004, + } + + /// + /// Exposes methods that either create or merge a shortcut menu associated with a Shell object. Allows client objects to handle messages associated with + /// owner-drawn menu items and extends IContextMenu2 by accepting a return value from that message handling. + /// + [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("000214E4-0000-0000-c000-000000000046")] + public interface IContextMenu + { + /// Adds commands to a shortcut menu. + /// A handle to the shortcut menu. The handler should specify this handle when adding menu items. + /// The zero-based position at which to insert the first new menu item. + /// The minimum value that the handler can specify for a menu item identifier. + /// The maximum value that the handler can specify for a menu item identifier. + /// Optional flags that specify how the shortcut menu can be changed. + /// + /// If successful, returns an HRESULT value that has its severity value set to SEVERITY_SUCCESS and its code value set to the offset of the largest + /// command identifier that was assigned, plus one. For example, if idCmdFirst is set to 5 and you add three items to the menu with command + /// identifiers of 5, 7, and 8, the return value should be MAKE_HRESULT(SEVERITY_SUCCESS, 0, 8 - 5 + 1). Otherwise, it returns a COM error value. + /// + [PreserveSig] + HRESULT QueryContextMenu(IntPtr hmenu, uint indexMenu, uint idCmdFirst, uint idCmdLast, CMF uFlags); + + /// Carries out the command associated with a shortcut menu item. + /// A pointer to a CMINVOKECOMMANDINFO or CMINVOKECOMMANDINFOEX structure that contains specifics about the command. + void InvokeCommand([In] ref CMINVOKECOMMANDINFOEX pici); + + /// + /// Gets information about a shortcut menu command, including the help string and the language-independent, or canonical, name for the command. + /// + /// Menu command identifier offset. + /// Flags specifying the information to return. + /// Reserved. Applications must specify NULL when calling this method and handlers must ignore this parameter when called. + /// The reference of the buffer to receive the null-terminated string being retrieved. + /// Size of the buffer, in characters, to receive the null-terminated string. + /// If the method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. + void GetCommandString(IntPtr idCmd, GCS uType, IntPtr pReserved, IntPtr pszName, uint cchMax); + } + + /// + /// Exposes methods that either create or merge a shortcut (context) menu associated with a Shell object. Extends IContextMenu by adding a method that + /// allows client objects to handle messages associated with owner-drawn menu items. + /// + [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("000214F4-0000-0000-c000-000000000046")] + public interface IContextMenu2 : IContextMenu + { + /// Adds commands to a shortcut menu. + /// A handle to the shortcut menu. The handler should specify this handle when adding menu items. + /// The zero-based position at which to insert the first new menu item. + /// The minimum value that the handler can specify for a menu item identifier. + /// The maximum value that the handler can specify for a menu item identifier. + /// Optional flags that specify how the shortcut menu can be changed. + /// + /// If successful, returns an HRESULT value that has its severity value set to SEVERITY_SUCCESS and its code value set to the offset of the largest + /// command identifier that was assigned, plus one. For example, if idCmdFirst is set to 5 and you add three items to the menu with command + /// identifiers of 5, 7, and 8, the return value should be MAKE_HRESULT(SEVERITY_SUCCESS, 0, 8 - 5 + 1). Otherwise, it returns a COM error value. + /// + [PreserveSig] + new HRESULT QueryContextMenu(IntPtr hmenu, uint indexMenu, uint idCmdFirst, uint idCmdLast, CMF uFlags); + + /// Carries out the command associated with a shortcut menu item. + /// A pointer to a CMINVOKECOMMANDINFO or CMINVOKECOMMANDINFOEX structure that contains specifics about the command. + new void InvokeCommand([In] ref CMINVOKECOMMANDINFOEX pici); + + /// + /// Gets information about a shortcut menu command, including the help string and the language-independent, or canonical, name for the command. + /// + /// Menu command identifier offset. + /// Flags specifying the information to return. + /// Reserved. Applications must specify NULL when calling this method and handlers must ignore this parameter when called. + /// The reference of the buffer to receive the null-terminated string being retrieved. + /// Size of the buffer, in characters, to receive the null-terminated string. + /// If the method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. + new void GetCommandString(IntPtr idCmd, GCS uType, IntPtr pReserved, IntPtr pszName, uint cchMax); + + /// Enables client objects of the IContextMenu interface to handle messages associated with owner-drawn menu items. + /// + /// The message to be processed. In the case of some messages, such as WM_INITMENUPOPUP, WM_DRAWITEM, WM_MENUCHAR, or WM_MEASUREITEM, the client + /// object being called may provide owner-drawn menu items. + /// + /// Additional message information. The value of this parameter depends on the value of the uMsg parameter. + /// Additional message information. The value of this parameter depends on the value of the uMsg parameter. + void HandleMenuMsg(uint uMsg, IntPtr wParam, IntPtr lParam); + } + + /// + /// Exposes methods that either create or merge a shortcut menu associated with a Shell object. Allows client objects to handle messages associated with + /// owner-drawn menu items and extends IContextMenu2 by accepting a return value from that message handling. + /// + [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), GuidAttribute("bcfce0a0-ec17-11d0-8d10-00a0c90f2719")] + public interface IContextMenu3 : IContextMenu2 + { + /// Adds commands to a shortcut menu. + /// A handle to the shortcut menu. The handler should specify this handle when adding menu items. + /// The zero-based position at which to insert the first new menu item. + /// The minimum value that the handler can specify for a menu item identifier. + /// The maximum value that the handler can specify for a menu item identifier. + /// Optional flags that specify how the shortcut menu can be changed. + /// + /// If successful, returns an HRESULT value that has its severity value set to SEVERITY_SUCCESS and its code value set to the offset of the largest + /// command identifier that was assigned, plus one. For example, if idCmdFirst is set to 5 and you add three items to the menu with command + /// identifiers of 5, 7, and 8, the return value should be MAKE_HRESULT(SEVERITY_SUCCESS, 0, 8 - 5 + 1). Otherwise, it returns a COM error value. + /// + [PreserveSig] + new HRESULT QueryContextMenu(IntPtr hmenu, uint indexMenu, uint idCmdFirst, uint idCmdLast, CMF uFlags); + + /// Carries out the command associated with a shortcut menu item. + /// A pointer to a CMINVOKECOMMANDINFO or CMINVOKECOMMANDINFOEX structure that contains specifics about the command. + new void InvokeCommand([In] ref CMINVOKECOMMANDINFOEX pici); + + /// + /// Gets information about a shortcut menu command, including the help string and the language-independent, or canonical, name for the command. + /// + /// Menu command identifier offset. + /// Flags specifying the information to return. + /// Reserved. Applications must specify NULL when calling this method and handlers must ignore this parameter when called. + /// The reference of the buffer to receive the null-terminated string being retrieved. + /// Size of the buffer, in characters, to receive the null-terminated string. + /// If the method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. + new void GetCommandString(IntPtr idCmd, GCS uType, IntPtr pReserved, IntPtr pszName, uint cchMax); + + /// Enables client objects of the IContextMenu interface to handle messages associated with owner-drawn menu items. + /// + /// The message to be processed. In the case of some messages, such as WM_INITMENUPOPUP, WM_DRAWITEM, WM_MENUCHAR, or WM_MEASUREITEM, the client + /// object being called may provide owner-drawn menu items. + /// + /// Additional message information. The value of this parameter depends on the value of the uMsg parameter. + /// Additional message information. The value of this parameter depends on the value of the uMsg parameter. + new void HandleMenuMsg(uint uMsg, IntPtr wParam, IntPtr lParam); + + /// Allows client objects of the IContextMenu3 interface to handle messages associated with owner-drawn menu items. + /// + /// The message to be processed. In the case of some messages, such as WM_INITMENUPOPUP, WM_DRAWITEM, WM_MENUCHAR, or WM_MEASUREITEM, the client + /// object being called may provide owner-drawn menu items. + /// + /// Additional message information. The value of this parameter depends on the value of the uMsg parameter. + /// Additional message information. The value of this parameter depends on the value of the uMsg parameter. + /// The address of an LRESULT value that the owner of the menu will return from the message. This parameter can be NULL. + void HandleMenuMsg2(uint uMsg, IntPtr wParam, IntPtr lParam, IntPtr result); + } + + /* + /// Contains information needed by IContextMenu::InvokeCommand to invoke a shortcut menu command. + [StructLayout(LayoutKind.Sequential)] + public struct CMINVOKECOMMANDINFO + { + public uint cbSize; + public CMIC fMask; + public IntPtr hwnd; + [MarshalAs(UnmanagedType.LPStr)] + public string lpVerb; + [MarshalAs(UnmanagedType.LPStr)] + public string lpParameters; + [MarshalAs(UnmanagedType.LPStr)] + public string lpDirectory; + public int nShow; + public uint dwHotKey; + public IntPtr hIcon; + } + */ + + /// + /// Contains extended information about a shortcut menu command. This structure is an extended version of CMINVOKECOMMANDINFO that allows the use of + /// Unicode values. + /// + [StructLayout(LayoutKind.Sequential)] + public struct CMINVOKECOMMANDINFOEX + { + /// + /// The size of this structure, in bytes. This member should be filled in by callers of IContextMenu::InvokeCommand and tested by the implementations + /// to know that the structure is a CMINVOKECOMMANDINFOEX structure rather than CMINVOKECOMMANDINFO. + /// + public uint cbSize; + /// + /// Zero, or one or more of the following flags are set to indicate desired behavior and indicate that other fields in the structure are to be used. + /// + public CMIC fMask; + /// + /// A handle to the window that is the owner of the shortcut menu. An extension can also use this handle as the owner of any message boxes or dialog + /// boxes it displays. Callers must specify a legitimate HWND that can be used as the owner window for any UI that may be displayed. Failing to + /// specify an HWND when calling from a UI thread (one with windows already created) will result in reentrancy and possible bugs in the + /// implementation of a IContextMenu::InvokeCommand call. + /// + public IntPtr hwnd; + /// + /// The address of a null-terminated string that specifies the language-independent name of the command to carry out. This member is typically a + /// string when a command is being activated by an application. + /// + /// + /// Constant + /// Command string + /// + /// + /// CMDSTR_RUNAS + /// "RunAs" + /// + /// + /// CMDSTR_PRINT + /// "Print" + /// + /// + /// CMDSTR_PREVIEW + /// "Preview" + /// + /// + /// CMDSTR_OPEN + /// "Open" + /// + /// + /// This is not a fixed set; new canonical verbs can be invented by context menu handlers and applications can invoke them. + /// + /// If a canonical verb exists and a menu handler does not implement the canonical verb, it must return a failure code to enable the next handler to + /// be able to handle this verb. Failing to do this will break functionality in the system including ShellExecute. + /// + /// + /// Alternatively, rather than a pointer, this parameter can be MAKEINTRESOURCE(offset) where offset is the menu-identifier offset of the command to + /// carry out. Implementations can use the IS_INTRESOURCE macro to detect that this alternative is being employed. The Shell uses this alternative + /// when the user chooses a menu command. + /// + /// + [MarshalAs(UnmanagedType.LPStr)] + public string lpVerb; + /// Optional parameters. This member is always NULL for menu items inserted by a Shell extension. + [MarshalAs(UnmanagedType.LPStr)] + public string lpParameters; + /// An optional working directory name. This member is always NULL for menu items inserted by a Shell extension. + [MarshalAs(UnmanagedType.LPStr)] + public string lpDirectory; + /// A set of SW_ values to pass to the ShowWindow function if the command displays a window or starts an application. + public ShowWindowCommand nShow; + /// + /// An optional keyboard shortcut to assign to any application activated by the command. If the fMask member does not specify CMIC_MASK_HOTKEY, this + /// member is ignored. + /// + public uint dwHotKey; + /// + /// An icon to use for any application activated by the command. If the fMask member does not specify CMIC_MASK_ICON, this member is ignored. + /// + public IntPtr hIcon; + /// An ASCII title. + [MarshalAs(UnmanagedType.LPStr)] + public string lpTitle; + /// A Unicode verb, for those commands that can use it. + [MarshalAs(UnmanagedType.LPWStr)] + public string lpVerbW; + /// A Unicode parameters, for those commands that can use it. + [MarshalAs(UnmanagedType.LPWStr)] + public string lpParametersW; + /// A Unicode directory, for those commands that can use it. + [MarshalAs(UnmanagedType.LPWStr)] + public string lpDirectoryW; + /// A Unicode title. + [MarshalAs(UnmanagedType.LPWStr)] + public string lpTitleW; + /// + /// The point where the command is invoked. If the fMask member does not specify CMIC_MASK_PTINVOKE, this member is ignored. This member is not valid + /// prior to Internet Explorer 4.0. + /// + public System.Drawing.Point ptInvoke; + } + } +} \ No newline at end of file diff --git a/PInvoke/Shell32/ShObjIdl.IInitializeWithFile.cs b/PInvoke/Shell32/ShObjIdl.IInitializeWithFile.cs new file mode 100644 index 00000000..1dc15af1 --- /dev/null +++ b/PInvoke/Shell32/ShObjIdl.IInitializeWithFile.cs @@ -0,0 +1,20 @@ +using System; +using System.Runtime.InteropServices; + +namespace Vanara.PInvoke +{ + public static partial class Shell32 + { + /// Exposes a method to initialize a handler, such as a property handler, thumbnail handler, or preview handler, with a file path. + [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("b7d14566-0509-4cce-a71f-0a554233bd9b")] + public interface IInitializeWithFile + { + /// + /// Initializes a handler with a file path. + /// + /// A pointer to a buffer that contains the file path as a null-terminated Unicode string. + /// One of the following STGM values that indicates the access mode for pszFilePath. + void Initialize([In, MarshalAs(UnmanagedType.LPWStr)] string pszFilePath, STGM grfMode); + } + } +} \ No newline at end of file diff --git a/PInvoke/Shell32/ShObjIdl.IInitializeWithItem.cs b/PInvoke/Shell32/ShObjIdl.IInitializeWithItem.cs new file mode 100644 index 00000000..ad397faa --- /dev/null +++ b/PInvoke/Shell32/ShObjIdl.IInitializeWithItem.cs @@ -0,0 +1,18 @@ +using System; +using System.Runtime.InteropServices; + +namespace Vanara.PInvoke +{ + public static partial class Shell32 + { + /// Exposes a method used to initialize a handler, such as a property handler, thumbnail handler, or preview handler, with an IShellItem. + [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("7f73be3f-fb79-493c-a6c7-7ee14e245841")] + public interface IInitializeWithItem + { + /// Initializes a handler with an IShellItem. + /// A pointer to an IShellItem. + /// One of the following STGM values that indicate the access mode for psi.. + void Initialize(IShellItem psi, STGM grfMode); + } + } +} \ No newline at end of file diff --git a/PInvoke/Shell32/ShObjIdl.IInitializeWithStream.cs b/PInvoke/Shell32/ShObjIdl.IInitializeWithStream.cs new file mode 100644 index 00000000..937ce47e --- /dev/null +++ b/PInvoke/Shell32/ShObjIdl.IInitializeWithStream.cs @@ -0,0 +1,19 @@ +using System; +using System.Runtime.InteropServices; +using System.Runtime.InteropServices.ComTypes; + +namespace Vanara.PInvoke +{ + public static partial class Shell32 + { + /// Exposes a method that initializes a handler, such as a property handler, thumbnail handler, or preview handler, with a stream. + [ComImport, Guid("b824b49d-22ac-4161-ac8a-9916e8fa3f7f"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + public interface IInitializeWithStream + { + /// Initializes a handler with a stream. + /// A pointer to an IStream interface that represents the stream source. + /// One of the following STGM values that indicates the access mode for pstream. + void Initialize([In] IStream pstream, STGM grfMode); + } + } +} \ No newline at end of file diff --git a/PInvoke/Shell32/ShObjIdl.IShellExtInit.cs b/PInvoke/Shell32/ShObjIdl.IShellExtInit.cs new file mode 100644 index 00000000..0f92acba --- /dev/null +++ b/PInvoke/Shell32/ShObjIdl.IShellExtInit.cs @@ -0,0 +1,27 @@ +using System; +using System.Runtime.InteropServices; +using System.Runtime.InteropServices.ComTypes; + +namespace Vanara.PInvoke +{ + public static partial class Shell32 + { + /// + /// Exposes a method that initializes Shell extensions for property sheets, shortcut menus, and drag-and-drop handlers (extensions that add items to + /// shortcut menus during nondefault drag-and-drop operations). + /// + [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("000214E8-0000-0000-c000-000000000046")] + public interface IShellExtInit + { + /// Initializes a property sheet extension, shortcut menu extension, or drag-and-drop handler. + /// + /// A pointer to an ITEMIDLIST structure that uniquely identifies a folder. For property sheet extensions, this parameter is NULL. For shortcut menu + /// extensions, it is the item identifier list for the folder that contains the item whose shortcut menu is being displayed. For nondefault + /// drag-and-drop menu extensions, this parameter specifies the target folder. + /// + /// A pointer to an IDataObject interface object that can be used to retrieve the objects being acted upon. + /// The registry key for the file object or folder type. + void Initialize(PIDL pidlFolder, [In] IDataObject pdtobj, uint hkeyProgId); + } + } +} \ No newline at end of file