.NET - WindowStyle =隐藏与CreateNoWindow =真的吗? [英] .NET - WindowStyle = hidden vs. CreateNoWindow = true?

查看:192
本文介绍了.NET - WindowStyle =隐藏与CreateNoWindow =真的吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我开始一个新的进程,又有什么区别,如果我用的是

When I start a new process, what difference does it make if I use the

WindowStyle = hidden

CreateNoWindow = true

的ProcessStartInfo 类的属性?

推荐答案

正如汉斯说,WindowStyle是传递给该过程的建议,应用程序可以选择忽略它。

As Hans said, WindowStyle is a recommendation passed to the process, the application can choose to ignore it.

CreateNoWindow控制如何在控制台工程的子进程,但它不单独工作。

CreateNoWindow controls how the console works for the child process, but it doesn't work alone.

CreateNoWindow与UseShellExecute一起工作如下:

CreateNoWindow works in conjunction with UseShellExecute as follows:

要没有任何窗口中运行过程:

To run the process without any window:

ProcessStartInfo info = new ProcessStartInfo(fileName, arg); 
info.CreateNoWindow = true; 
info.UseShellExecute = false;
Process processChild = Process.Start(info); 

要运行的子进程在它自己的窗口中(新的控制台)

To run the child process in it's own window (new console)

UseShellExecute = true; // which is the default value.
ProcessStartInfo info = new ProcessStartInfo(fileName, arg); 
Process processChild = Process.Start(info); // separate window

要运行的子进程在父的控制台窗口

To run the child process in the parent's console window

UseShellExecute = false;
ProcessStartInfo info = new ProcessStartInfo(fileName, arg); 
info.UseShellExecute = false; // causes consoles to share window 
Process processChild = Process.Start(info); 

这篇关于.NET - WindowStyle =隐藏与CreateNoWindow =真的吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆