mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-26 16:54:01 +00:00
Exposing STARTUPINFOW.wShowWindow in CommandExt (show_window function) to control how a new process should display its window (normal, minimized, maximized, etc)
This commit is contained in:
parent
7d640b670e
commit
06d76c3156
@ -181,6 +181,13 @@ pub trait CommandExt: Sealed {
|
|||||||
#[stable(feature = "windows_process_extensions", since = "1.16.0")]
|
#[stable(feature = "windows_process_extensions", since = "1.16.0")]
|
||||||
fn creation_flags(&mut self, flags: u32) -> &mut process::Command;
|
fn creation_flags(&mut self, flags: u32) -> &mut process::Command;
|
||||||
|
|
||||||
|
/// Sets the field [wShowWindow][1] of [STARTUPINFO][2] that is passed to `CreateProcess`.
|
||||||
|
///
|
||||||
|
/// [1]: https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-showwindow
|
||||||
|
/// [2]: https://learn.microsoft.com/es-es/windows/win32/api/processthreadsapi/ns-processthreadsapi-startupinfow
|
||||||
|
#[unstable(feature = "windows_process_extensions_show_window", issue = "none")]
|
||||||
|
fn show_window(&mut self, cmd_show: u16) -> &mut process::Command;
|
||||||
|
|
||||||
/// Forces all arguments to be wrapped in quote (`"`) characters.
|
/// Forces all arguments to be wrapped in quote (`"`) characters.
|
||||||
///
|
///
|
||||||
/// This is useful for passing arguments to [MSYS2/Cygwin][1] based
|
/// This is useful for passing arguments to [MSYS2/Cygwin][1] based
|
||||||
@ -370,6 +377,11 @@ impl CommandExt for process::Command {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn show_window(&mut self, cmd_show: u16) -> &mut process::Command {
|
||||||
|
self.as_inner_mut().show_window(Some(cmd_show));
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
fn force_quotes(&mut self, enabled: bool) -> &mut process::Command {
|
fn force_quotes(&mut self, enabled: bool) -> &mut process::Command {
|
||||||
self.as_inner_mut().force_quotes(enabled);
|
self.as_inner_mut().force_quotes(enabled);
|
||||||
self
|
self
|
||||||
|
@ -163,6 +163,7 @@ pub struct Command {
|
|||||||
env: CommandEnv,
|
env: CommandEnv,
|
||||||
cwd: Option<OsString>,
|
cwd: Option<OsString>,
|
||||||
flags: u32,
|
flags: u32,
|
||||||
|
show_window: Option<u16>,
|
||||||
detach: bool, // not currently exposed in std::process
|
detach: bool, // not currently exposed in std::process
|
||||||
stdin: Option<Stdio>,
|
stdin: Option<Stdio>,
|
||||||
stdout: Option<Stdio>,
|
stdout: Option<Stdio>,
|
||||||
@ -194,6 +195,7 @@ impl Command {
|
|||||||
env: Default::default(),
|
env: Default::default(),
|
||||||
cwd: None,
|
cwd: None,
|
||||||
flags: 0,
|
flags: 0,
|
||||||
|
show_window: None,
|
||||||
detach: false,
|
detach: false,
|
||||||
stdin: None,
|
stdin: None,
|
||||||
stdout: None,
|
stdout: None,
|
||||||
@ -224,6 +226,9 @@ impl Command {
|
|||||||
pub fn creation_flags(&mut self, flags: u32) {
|
pub fn creation_flags(&mut self, flags: u32) {
|
||||||
self.flags = flags;
|
self.flags = flags;
|
||||||
}
|
}
|
||||||
|
pub fn show_window(&mut self, cmd_show: Option<u16>) {
|
||||||
|
self.show_window = cmd_show;
|
||||||
|
}
|
||||||
|
|
||||||
pub fn force_quotes(&mut self, enabled: bool) {
|
pub fn force_quotes(&mut self, enabled: bool) {
|
||||||
self.force_quotes_enabled = enabled;
|
self.force_quotes_enabled = enabled;
|
||||||
@ -337,6 +342,11 @@ impl Command {
|
|||||||
si.hStdError = stderr.as_raw_handle();
|
si.hStdError = stderr.as_raw_handle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let Some(cmd_show) = self.show_window {
|
||||||
|
si.dwFlags |= c::STARTF_USESHOWWINDOW;
|
||||||
|
si.wShowWindow = cmd_show;
|
||||||
|
}
|
||||||
|
|
||||||
let si_ptr: *mut c::STARTUPINFOW;
|
let si_ptr: *mut c::STARTUPINFOW;
|
||||||
|
|
||||||
let mut proc_thread_attribute_list;
|
let mut proc_thread_attribute_list;
|
||||||
|
Loading…
Reference in New Issue
Block a user