From ec39c32d8352bc45ce04c0faa9712d932425325e Mon Sep 17 00:00:00 2001 From: David Hall Date: Tue, 22 Jan 2019 19:54:52 -0800 Subject: [PATCH] Added IInitializeCommand --- PInvoke/Shell32/ShObjIdl.IExecuteCommand.cs | 53 +++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/PInvoke/Shell32/ShObjIdl.IExecuteCommand.cs b/PInvoke/Shell32/ShObjIdl.IExecuteCommand.cs index aa51a8e8..fa950bba 100644 --- a/PInvoke/Shell32/ShObjIdl.IExecuteCommand.cs +++ b/PInvoke/Shell32/ShObjIdl.IExecuteCommand.cs @@ -1,6 +1,7 @@ using System; using System.Drawing; using System.Runtime.InteropServices; +using static Vanara.PInvoke.Ole32; namespace Vanara.PInvoke { @@ -170,5 +171,57 @@ namespace Vanara.PInvoke [PreserveSig] HRESULT Execute(); } + + /// + /// Exposes a single method used to initialize objects that implement IExplorerCommandState, IExecuteCommand or IDropTarget with the + /// application-specified command name and its registered properties. + /// + /// + /// When to Implement + /// Implement IInitializeCommand in the following situations. + /// + /// + /// + /// Implement this interface to differentiate between related commands that share implementations of IExplorerCommandState, + /// IDropTarget or IExecuteCommand. Differentiation is made through the command name passed in IInitializeCommand::Initialize. + /// Commands can also use Initialize to pass a specific property bag for the command, using properties the command has placed + /// in the registry. + /// + /// + /// + /// When to Use + /// + /// Do not call the method of IInitializeCommand directly. Windows Explorer calls this method when a verb object that + /// implements this interface is invoked. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/shobjidl_core/nn-shobjidl_core-iinitializecommand + [PInvokeData("shobjidl_core.h", MSDNShortId = "e5a2a4d3-2488-4da2-aaab-c27461859d9f")] + [ComImport, Guid("85075acf-231f-40ea-9610-d26b7b58f638"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + public interface IInitializeCommand + { + /// + /// Initialize objects that share an implementation of IExplorerCommandState, IExecuteCommand or IDropTarget with the + /// application-specified command name and its registered properties. + /// + /// Type: LPCWSTR + /// + /// Pointer to a string that contains the command name (the name of the command key as found in the registry). For instance, if + /// the command is registered under ...<b>shell<b>MyCommand, pszCommandName points to "MyCommand". + /// + /// Type: IPropertyBag* + /// + /// Pointer to an IPropertyBag instance that can be used to read the properties related to the command in the registry. For + /// example, a command may registry a string property under its ...<b>shell<b>MyCommand subkey. + /// + /// + /// Type: HRESULT + /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/shobjidl_core/nf-shobjidl_core-iinitializecommand-initialize + // HRESULT Initialize( LPCWSTR pszCommandName, IPropertyBag *ppb ); + [PreserveSig] + HRESULT Initialize([In, MarshalAs(UnmanagedType.LPWStr)] string pszCommandName, [In] IPropertyBag ppb); + } } } \ No newline at end of file