Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitfe62f6f

Browse files
author
Andres Olivares
committed
Exposing STARTUPINFOW.wShowWindow in CommandExt (show_window function) to control how a new process should display its window (normal, minimized, maximized, etc)
1 parentc5f1c76 commitfe62f6f

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

‎std/src/os/windows/process.rs‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,13 @@ pub trait CommandExt: Sealed {
181181
#[stable(feature ="windows_process_extensions", since ="1.16.0")]
182182
fncreation_flags(&mutself,flags:u32) ->&mut process::Command;
183183

184+
/// Sets the field [wShowWindow][1] of [STARTUPINFO][2] that is passed to `CreateProcess`.
185+
///
186+
/// [1]: https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-showwindow
187+
/// [2]: https://learn.microsoft.com/es-es/windows/win32/api/processthreadsapi/ns-processthreadsapi-startupinfow
188+
#[unstable(feature ="windows_process_extensions_show_window", issue ="none")]
189+
fnshow_window(&mutself,cmd_show:u16) ->&mut process::Command;
190+
184191
/// Forces all arguments to be wrapped in quote (`"`) characters.
185192
///
186193
/// This is useful for passing arguments to [MSYS2/Cygwin][1] based
@@ -370,6 +377,11 @@ impl CommandExt for process::Command {
370377
self
371378
}
372379

380+
fnshow_window(&mutself,cmd_show:u16) ->&mut process::Command{
381+
self.as_inner_mut().show_window(Some(cmd_show));
382+
self
383+
}
384+
373385
fnforce_quotes(&mutself,enabled:bool) ->&mut process::Command{
374386
self.as_inner_mut().force_quotes(enabled);
375387
self

‎std/src/sys/pal/windows/process.rs‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ pub struct Command {
163163
env:CommandEnv,
164164
cwd:Option<OsString>,
165165
flags:u32,
166+
show_window:Option<u16>,
166167
detach:bool,// not currently exposed in std::process
167168
stdin:Option<Stdio>,
168169
stdout:Option<Stdio>,
@@ -194,6 +195,7 @@ impl Command {
194195
env:Default::default(),
195196
cwd:None,
196197
flags:0,
198+
show_window:None,
197199
detach:false,
198200
stdin:None,
199201
stdout:None,
@@ -224,6 +226,9 @@ impl Command {
224226
pubfncreation_flags(&mutself,flags:u32){
225227
self.flags = flags;
226228
}
229+
pubfnshow_window(&mutself,cmd_show:Option<u16>){
230+
self.show_window = cmd_show;
231+
}
227232

228233
pubfnforce_quotes(&mutself,enabled:bool){
229234
self.force_quotes_enabled = enabled;
@@ -337,6 +342,11 @@ impl Command {
337342
si.hStdError = stderr.as_raw_handle();
338343
}
339344

345+
ifletSome(cmd_show) =self.show_window{
346+
si.dwFlags |= c::STARTF_USESHOWWINDOW;
347+
si.wShowWindow = cmd_show;
348+
}
349+
340350
let si_ptr:*mut c::STARTUPINFOW;
341351

342352
letmut proc_thread_attribute_list;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp