本文整理汇总了C#中System.Diagnostics.Process.CloseMainWindow方法的典型用法代码示例。如果您正苦于以下问题:C# System.Diagnostics.Process.CloseMainWindow方法的具体用法?C# System.Diagnostics.Process.CloseMainWindow怎么用?C# System.Diagnostics.Process.CloseMainWindow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Diagnostics.Process
的用法示例。
在下文中一共展示了System.Diagnostics.Process.CloseMainWindow方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: runShellCommand
internal static bool runShellCommand(string command) {
System.Diagnostics.Process p = new System.Diagnostics.Process {
StartInfo = new System.Diagnostics.ProcessStartInfo {
WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden,
FileName = "cmd.exe",
Arguments = (@"CMD /C " + command)
}
};
p.Start();
p.WaitForExit(5000);
if (p.HasExited == false) { //Check to see if the process is still running.
if (p.Responding) {//Test to see if the process is hung up.
p.CloseMainWindow();//Process was responding; close the main window.
return false;
} else {
p.Kill(); //Process was not responding; force the process to close.
return false;
}
}
return true;
}
示例2: ExecProc
/// <summary>
/// Instantiate a new process to execute the application in the given path.
/// This is used primary to install/uninstall individual keyboard msi builds.
/// </summary>
/// <param name="path">The path to the application to install</param>
/// <param name="arg">Arguments to pass to the application</param>
/// <param name="wait">Wait for the process to complete before returning.</param>
private void ExecProc(string path, string arg, bool wait)
{
//create the process instance to execute the application.
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.EnableRaisingEvents = true;
proc.Exited += new EventHandler(proc_Exited);
proc.StartInfo.FileName = path;
proc.StartInfo.Arguments = arg;
proc.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal;
this.WindowState = FormWindowState.Minimized;
proc.Start();
//wait for the process to finish.
if (wait == true)
{
proc.WaitForExit();
if (proc.HasExited == false)
proc.CloseMainWindow();
}
}