using System; using System.Drawing; using System.Runtime.InteropServices; using static Vanara.PInvoke.OleAut32; namespace Vanara.PInvoke { public static partial class Shell32 { /// /// Exposes methods that set a given state or parameter related to the command verb, as well as a method to invoke that verb. /// /// /// When to Implement /// /// Implement this interface when you choose it as your method to invoke the verb to perform an action on selected items. The items /// are passed as a Shell item array through IObjectWithSelection::SetSelection, so the object must also implement IObjectWithSelection. /// /// When to Use /// /// Do not call the methods of IExecuteCommand directly. Windows Explorer calls your IExecuteCommand methods when the /// user wants to perform an action on the items. /// /// /// Note that, apart from Execute, the methods of this interface pass system information to the handler. The system itself calls /// these methods, setting the parameters appropriately based on system settings and conditions. /// /// // https://docs.microsoft.com/en-us/windows/desktop/api/shobjidl_core/nn-shobjidl_core-iexecutecommand [PInvokeData("shobjidl_core.h", MSDNShortId = "a3432f1a-dd33-4e0d-8b26-1312bb5151f7")] [ComImport, Guid("7F9185B0-CB92-43c5-80A9-92277A4F7B54"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IExecuteCommand { /// Sets a value based on the current state of the keys CTRL and SHIFT. /// /// Type: DWORD /// One or both of the following flags to indicate whether the key is pressed. /// MK_CONTROL /// The CTRL key is pressed. /// MK_SHIFT /// The SHIFT key is pressed. /// /// /// 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-iexecutecommand-setkeystate HRESULT // SetKeyState( DWORD grfKeyState ); [PreserveSig] HRESULT SetKeyState(User32.MouseButtonState grfKeyState); /// Provides parameter values for the verb. /// /// Type: LPCWSTR /// /// Pointer to a string that contains parameter values. The format and contents of this string is determined by the verb that is /// to be invoked. /// /// /// /// 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-iexecutecommand-setparameters HRESULT // SetParameters( LPCWSTR pszParameters ); [PreserveSig] HRESULT SetParameters([In, MarshalAs(UnmanagedType.LPWStr)] string pszParameters); /// Sets the coordinates of a point used for display. /// /// Type: POINT /// /// The screen coordinates at which the user right-clicked to invoke the shortcut menu from which a command was chosen. /// Applications can use this information to present any UI. This is particularly useful in a multi-monitor situation. The /// default position is the center of the default monitor. /// /// /// /// 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-iexecutecommand-setposition HRESULT // SetPosition( POINT pt ); [PreserveSig] HRESULT SetPosition(Point pt); /// Sets the specified window's visual state. /// /// Type: int /// One of the following flags to indicate how the window is to be shown. /// SW_HIDE /// Hides the window and activates another window. /// SW_MAXIMIZE /// Maximizes the specified window. /// SW_MINIMIZE /// Minimizes the specified window and activates the next top-level window in the z-order. /// SW_RESTORE /// /// Activates and displays the window. If the window is minimized or maximized, Windows restores it to its original size and /// position. An application should specify this flag when restoring a minimized window. /// /// SW_SHOW /// Activates the window and displays it in its current size and position. /// SW_SHOWDEFAULT /// /// Sets the show state based on the information specified in the STARTUPINFO structure passed to the CreateProcess function that /// started the application. An application should call ShowWindow with this flag to set the initial visual state of its main window. /// /// SW_SHOWMAXIMIZED /// Activates the window and displays it as a maximized window. /// SW_SHOWMINIMIZED /// Activates the window and displays it as a minimized window. /// SW_SHOWMINNOACTIVE /// Displays the window as a minimized window. The active window remains active. /// SW_SHOWNA /// Displays the window in its current state. The active window remains active. /// SW_SHOWNOACTIVATE /// Displays a window in its most recent size and position. The active window remains active. /// SW_SHOWNORMAL /// /// Default state. Activates and displays a window. If the window is minimized or maximized, Windows restores it to its original /// size and position. An application should specify this flag when it displays the window for the first time. /// /// /// /// 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-iexecutecommand-setshowwindow HRESULT // SetShowWindow( int nShow ); [PreserveSig] HRESULT SetShowWindow(ShowWindowCommand nShow); /// Indicates whether any UI associated with the selected Shell item should be displayed. /// /// Type: BOOL /// TRUE to block display of any associated UI; FALSE to display the UI. FALSE is the default value. /// /// /// 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-iexecutecommand-setnoshowui HRESULT // SetNoShowUI( BOOL fNoShowUI ); [PreserveSig] HRESULT SetNoShowUI([MarshalAs(UnmanagedType.Bool)] bool fNoShowUI); /// Sets a new working directory. /// /// Type: LPCWSTR /// /// Pointer to a null-terminated string with the fully qualified path of the new working directory. If this value is NULL, /// the current working directory is used. /// /// /// /// 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-iexecutecommand-setdirectory HRESULT // SetDirectory( LPCWSTR pszDirectory ); [PreserveSig] HRESULT SetDirectory([In, MarshalAs(UnmanagedType.LPWStr)] string pszDirectory); /// Invoke the verb on the selected items. Call this method after you have called the other methods of this interface. /// /// 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-iexecutecommand-execute HRESULT Execute( ); [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); } } }