using System; using System.Runtime.InteropServices; using static Vanara.PInvoke.Kernel32; namespace Vanara.PInvoke { public static partial class Shell32 { /// Used by the ICreatingProcess interface to alter some parameters of the process that is being created. /// /// Applications do not implement this interface. /// A pointer to this interface is passed to ICreatingProcess::OnCreating. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nn-shobjidl_core-icreateprocessinputs [PInvokeData("shobjidl_core.h", MSDNShortId = "NN:shobjidl_core.ICreateProcessInputs")] [ComImport, Guid("F6EF6140-E26F-4D82-bAC4-E9BA5FD239A8"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface ICreateProcessInputs { /// Gets the additional flags that will be passed to CreateProcess. /// /// A pointer to a DWORD which receives the flags that will be passed as the dwCreationFlags parameter to CreateProcess. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-icreateprocessinputs-getcreateflags HRESULT // GetCreateFlags( DWORD *pdwCreationFlags ); CREATE_PROCESS GetCreateFlags(); /// Set the flags that will be included in the call to CreateProcess. /// The flags that will be passed to the dwCreationFlags parameter to CreateProcess. /// /// Any flags set by a previous call to AddCreateFlags or SetCreateFlags will be replaced by the values specified by /// dwCreationFlags. Use AddCreateFlags to set flags without clearing flags that are already set. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-icreateprocessinputs-setcreateflags HRESULT // SetCreateFlags( DWORD dwCreationFlags ); void SetCreateFlags(CREATE_PROCESS dwCreationFlags); /// Set additional flags that will be included in the call to CreateProcess. /// The flags that will be included in the dwCreationFlags parameter passed to CreateProcess. /// Any creation flags that were previously set will remain set. This method does not clear any creation flags. // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-icreateprocessinputs-addcreateflags HRESULT // AddCreateFlags( DWORD dwCreationFlags ); void AddCreateFlags(CREATE_PROCESS dwCreationFlags); /// Sets the hot key for the application. /// /// The hotkey to assign to the application. See the documentation of the hStdIn member of the /// structure for more information. /// /// /// This method also sets the STARTF_USEHOTKEY flag in the dwFlags member of the STARTUPINFO structure passed to CreateProcess. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-icreateprocessinputs-sethotkey HRESULT // SetHotKey( WORD wHotKey ); void SetHotKey(ushort wHotKey); /// Additional flags that will be included in the structure passed to CreateProcess. /// /// The flags that will be included in the member passed to CreateProcess. /// /// Any creation flags that were previously set will remain set. This method does not clear any creation flags. // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-icreateprocessinputs-addstartupflags // HRESULT AddStartupFlags( DWORD dwStartupInfoFlags ); void AddStartupFlags(STARTF dwStartupInfoFlags); /// Sets the title that will be passed CreateProcess. /// /// A null-terminated string specifying the title that will be passed in the lpTitle member of the STARTUPINFO structure /// passed to CreateProcess. This parameter may not be NULL. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-icreateprocessinputs-settitle HRESULT // SetTitle( LPCWSTR pszTitle ); void SetTitle([MarshalAs(UnmanagedType.LPWStr)] string pszTitle); /// Sets a variable in the environment of the created process. /// /// A null-terminated string specifying the name of a variable to be set in the environment of the process to be created. This /// parameter may not be NULL. /// /// /// A null-terminated string specifying the value of the variable to be set in the environment of the process to be created. his /// parameter may not be NULL. /// /// If a variable with the same name already exists in the environment of the created process, it is replaced. // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-icreateprocessinputs-setenvironmentvariable // HRESULT SetEnvironmentVariable( LPCWSTR pszName, LPCWSTR pszValue ); void SetEnvironmentVariable([MarshalAs(UnmanagedType.LPWStr)] string pszName, [MarshalAs(UnmanagedType.LPWStr)] string pszValue); } /// Used by ShellExecuteEx and IContextMenu to allow the caller to alter some parameters of the process being created. /// /// /// The caller should install an object into the site chain which implements IServiceProvider::QueryService and responds to the /// SID_ExecuteCreatingProcess service ID with an object that implements the ICreatingProcess interface. /// /// /// After performing the desired operations, the object should forward the ICreatingProcess::OnCreating call up the site chain to /// allow other members of the site chain to participate. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nn-shobjidl_core-icreatingprocess [PInvokeData("shobjidl_core.h", MSDNShortId = "NN:shobjidl_core.ICreatingProcess")] [ComImport, Guid("c2b937a9-3110-4398-8a56-f34c6342d244"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface ICreatingProcess { /// Allows you to modify the parameters of the process being created. /// /// A pointer to an ICreateProcessInputs interface which allows you to set some parameters for the process that is being created. /// /// S_OK if the method succeeds. Otherwise, an HRESULT error code, and the process is not created. // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-icreatingprocess-oncreating HRESULT // OnCreating( ICreateProcessInputs *pcpi ); [PreserveSig] HRESULT OnCreating([In] ICreateProcessInputs pcpi); } } }