.NET - WindowStyle = hidden vs. CreateNoWindow = true?

后端 未结 3 1647
半阙折子戏
半阙折子戏 2020-11-27 12:55

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

WindowStyle = Hidden

or the

CreateNoWindow = true
<         


        
3条回答
  •  情话喂你
    2020-11-27 13:16

    Using Reflector, it looks like WindowStyle is used if UseShellExecute is set, otherwise it uses CreateNoWindow.

    In MSDN's example, you can see how they set it:

    // Using CreateNoWindow requires UseShellExecute to be false
    myProcess.StartInfo.UseShellExecute = false;
    // You can start any process, HelloWorld is a do-nothing example.
    myProcess.StartInfo.FileName = "C:\\HelloWorld.exe";
    myProcess.StartInfo.CreateNoWindow = true;
    myProcess.Start();
    

    In the other example, its just below because UseShellExecute is defaulted to true

    // UseShellExecute defaults to true, so use the WindowStyle
    ProcessStartInfo startInfo = new ProcessStartInfo("IExplore.exe");
    startInfo.WindowStyle = ProcessWindowStyle.Minimized;
    

提交回复
热议问题