ProcessStartInfo.CreateNoWindow Tulajdonság
Definíció
Fontos
Egyes információk olyan, kiadás előtti termékekre vonatkoznak, amelyek a kiadásig még jelentősen módosulhatnak. A Microsoft nem vállal kifejezett vagy törvényi garanciát az itt megjelenő információért.
Lekéri vagy beállítja azt az értéket, amely jelzi, hogy a folyamatot egy új ablakban kell-e elindítani.
public:
property bool CreateNoWindow { bool get(); void set(bool value); };
public bool CreateNoWindow { get; set; }
member this.CreateNoWindow : bool with get, set
Public Property CreateNoWindow As Boolean
Tulajdonság értéke
trueha a folyamatot úgy kell elindítani, hogy nem hoz létre egy új ablakot, amely tartalmazza azt; egyéb esetben. false Az alapértelmezett érték a false.
Példák
using System;
using System.Diagnostics;
using System.ComponentModel;
namespace MyProcessSample
{
class MyProcess
{
public static void Main()
{
try
{
using (Process myProcess = new Process())
{
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();
// This code assumes the process you are starting will terminate itself.
// Given that it is started without a window so you cannot terminate it
// on the desktop, it must terminate itself or you can do it programmatically
// from this application using the Kill method.
}
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
}
}
Imports System.Diagnostics
Imports System.ComponentModel
Namespace MyProcessSample
Class MyProcess
Public Shared Sub Main()
Try
Using myProcess As New Process()
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()
' This code assumes the process you are starting will terminate itself.
' Given that it is started without a window so you cannot terminate it
' on the desktop, it must terminate itself or you can do it programmatically
' from this application using the Kill method.
End Using
Catch e As Exception
Console.WriteLine((e.Message))
End Try
End Sub
End Class
End Namespace
Megjegyzések
Ha a UseShellExecute tulajdonság vagy true a UserNamePassword tulajdonságok nem null, a CreateNoWindow tulajdonság értéke figyelmen kívül lesz hagyva, és létrejön egy új ablak.
.NET Core nem támogatja közvetlenül Unix-szerű platformokon a windowsok létrehozását, beleértve a macOS-t és a Linuxot is. Ez a tulajdonság figyelmen kívül lesz hagyva az ilyen platformokon.