diff --git a/PInvoke/Shell32/ShObjIdl.IExecuteCommand.cs b/PInvoke/Shell32/ShObjIdl.IExecuteCommand.cs new file mode 100644 index 00000000..aa51a8e8 --- /dev/null +++ b/PInvoke/Shell32/ShObjIdl.IExecuteCommand.cs @@ -0,0 +1,174 @@ +using System; +using System.Drawing; +using System.Runtime.InteropServices; + +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(); + } + } +} \ No newline at end of file