本文整理汇总了C#中Process.CloseMainWindow方法的典型用法代码示例。如果您正苦于以下问题:C# Process.CloseMainWindow方法的具体用法?C# Process.CloseMainWindow怎么用?C# Process.CloseMainWindow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Process
的用法示例。
在下文中一共展示了Process.CloseMainWindow方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DoUnPack
/// <summary>
/// 解压开始
/// </summary>
public void DoUnPack()
{
Console.WriteLine("开始解压......");
RegistryKey reg;
string rarPath;
Process process = new Process();
try
{
reg = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\WinRAR.exe");
rarPath = reg.GetValue("").ToString();
process.StartInfo.FileName = rarPath;
//process.StartInfo.CreateNoWindow = true;
process.StartInfo.UseShellExecute = false;
// -0+ 如果已经存在则覆盖
process.StartInfo.Arguments = "x " + FilePath + " " + UnPackDirectory ;//这里是命令行 请参考winrar的说明
//开始解压
process.Start();
//进程终止
if (process.HasExited)
{
int exitCode = process.ExitCode;
if (exitCode == 0)
Console.WriteLine("{0} 正常完成", exitCode.ToString());
else
Console.WriteLine("{0} 正常完成", exitCode.ToString());
}
Console.WriteLine("解压完成");
}
catch (Exception ex)
{
throw ex;
}
finally
{
//释放资源
// process.Close();
process.CloseMainWindow();
process.WaitForExit();
//
}
}
示例2: ShutdownKinect
public void ShutdownKinect()
{
_isStarted = false;
if (_otherProcess == null)
{
return;
}
try
{
Process.GetProcessById(_otherProcess.Id);
}
catch (ArgumentException)
{
// The other app might have been shut down externally already.
_otherProcess = null;
return;
}
try
{
_otherProcess.CloseMainWindow();
_otherProcess.Close();
}
catch (InvalidOperationException)
{
// The other app might have been shut down externally already.
}
finally
{
_otherProcess = null;
}
}