.NET - WindowStyle = hidden vs. CreateNoWindow = true?
2021-01-02 21:29
标签:print within round you form link log row obj As Hans said, WindowStyle is a recommendation passed to the process, the application can choose to ignore it. CreateNoWindow controls how the console works for the child process, but it doesn‘t work alone. CreateNoWindow works in conjunction with UseShellExecute as follows: To run the process without any window: To run the child process in its own window (new console) To run the child process in the parent‘s console window If the UseShellExecute property is .NET Core does not support creating windows directly on Unix-like platforms, including macOS and Linux. This property is ignored on such platforms. Setting this property to The word "shell" in this context ( Note UseShellExecute must be When you use the operating system shell to start processes, you can start any document (which is any registered file type associated with an executable that has a default open action) and perform operations on the file, such as printing, by using the Process object. When UseShellExecute is Note UseShellExecute must be If you set the WindowStyle to ProcessWindowStyle.Hidden, UseShellExecute must be set to The WorkingDirectory property behaves differently depending on the value of the UseShellExecute property. When UseShellExecute is When UseShellExecute is .NET - WindowStyle = hidden vs. CreateNoWindow = true? 标签:print within round you form link log row obj 原文地址:https://www.cnblogs.com/chucklu/p/13214745.html.NET - WindowStyle = hidden vs. CreateNoWindow = true?
ProcessStartInfo info = new ProcessStartInfo(fileName, arg);
info.CreateNoWindow = true;
info.UseShellExecute = false;
Process processChild = Process.Start(info);
ProcessStartInfo info = new ProcessStartInfo(fileName, arg);
info.UseShellExecute = true; // which is the default value.
Process processChild = Process.Start(info); // separate window
ProcessStartInfo info = new ProcessStartInfo(fileName, arg);
info.UseShellExecute = false; // causes consoles to share window
Process processChild = Process.Start(info);
ProcessStartInfo.CreateNoWindow Property
true
if the process should be started without creating a new window to contain it; otherwise, false
. The default is false
.Remarks
true
or the UserName and Password properties are not null
, the CreateNoWindow property value is ignored and a new window is created.ProcessStartInfo.UseShellExecute Property
true
if the shell should be used when starting the process; false
if the process should be created directly from the executable file. The default is true
on .NET Framework apps and false
on .NET Core apps.Remarks
false
enables you to redirect input, output, and error streams.UseShellExecute
) refers to a graphical shell (similar to the Windows shell) rather than command shells (for example, bash
or sh
) and lets users launch graphical applications or open documents.false
if the UserName property is not null
or an empty string, or an InvalidOperationException will be thrown when the Process.Start(ProcessStartInfo) method is called.false
, you can start only executables by using the Process object.true
if you set the ErrorDialog property to true
.true
.WorkingDirectory
true
, the WorkingDirectory property specifies the location of the executable. If WorkingDirectory is an empty string, it is assumed that the current directory contains the executable.false
, the WorkingDirectory property is not used to find the executable. Instead, it is used only by the process that is started and has meaning only within the context of the new process. When UseShellExecute is false
, the FileName property can be either a fully qualified path to the executable, or a simple executable name that the system will attempt to find within folders specified by the PATH environment variable.
文章标题:.NET - WindowStyle = hidden vs. CreateNoWindow = true?
文章链接:http://soscw.com/index.php/essay/39669.html