C#操作windows系统进程的方法
作者:igoo 时间:2023-09-01 03:13:26
本文实例讲述了C#操作windows系统进程的方法。分享给大家供大家参考。具体如下:
这段代码演示了如何根据进程名关闭进程和启动进程
/// <summary>
/// 关闭进程
/// </summary>
private bool CloseProcess(string CloseProcessName)
{
try
{
//根据进程名称,获取该进程信息
Process[] MyProcessS = Process.GetProcessesByName(CloseProcessName);
foreach (Process MyProcess in MyProcessS)
{
MyProcess.Kill();
MyProcess.WaitForExit();
MyProcess.Close();
Thread.Sleep(10000);
}
}
catch (Exception)
{
return false;
}
return true;
}
/// <summary>
/// 创建进程
/// </summary>
public bool StartProcess(string StartProPath)
{
try
{
Process TheStartProcess = Process.Start(StartProPath);
}
catch (Exception)
{
return false;
}
return true;
}
希望本文所述对大家的C#程序设计有所帮助。
标签:C#,进程
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Android Drawable必备知识小结
2021-09-09 20:56:16
![](https://img.aspxhome.com/file/2023/8/138278_0s.jpg)
一文详解Object类和抽象类
2023-06-09 16:27:14
![](https://img.aspxhome.com/file/2023/8/79238_0s.png)
java 实现文件复制和格式更改的实例
2023-10-21 08:07:49
新手小白看过来学JAVA必过IO流File字节流字符流
2022-09-22 07:42:02
![](https://img.aspxhome.com/file/2023/8/69908_0s.jpg)
Android简单音乐播放实例
2023-04-13 05:49:55
![](https://img.aspxhome.com/file/2023/4/138364_0s.png)
关于Android中WebView远程代码执行漏洞浅析
2023-02-21 13:36:21
![](https://img.aspxhome.com/file/2023/7/126667_0s.jpg)
实例讲解Java的Spring框架中的控制反转和依赖注入
2023-04-24 17:44:49
![](https://img.aspxhome.com/file/2023/8/76228_0s.jpg)
C# 泛型字典 Dictionary的使用详解
2022-01-19 23:48:17
![](https://img.aspxhome.com/file/2023/8/102258_0s.png)
java二维数组遍历的2种代码
2022-05-03 08:52:50
![](https://img.aspxhome.com/file/2023/7/63997_0s.png)
Java调用Shell命令和脚本的实现
2023-11-29 00:59:09
Android开发之ProgressBar字体随着进度条的加载而滚动
2023-12-28 03:06:53
![](https://img.aspxhome.com/file/2023/4/138944_0s.gif)
Android获取SD卡路径及SDCard内存的方法
2021-12-30 17:04:58
C#以太网Sockets服务器设计实现
2023-10-10 04:38:32
java实现解析二进制文件的方法(字符串、图片)
2023-04-18 19:07:51
自定义类加载器以及打破双亲委派模型解析
2023-06-22 22:03:59
![](https://img.aspxhome.com/file/2023/0/57400_0s.png)
Java实现插入排序实例
2023-02-13 17:09:21
java使用gzip实现文件解压缩示例
2021-09-05 06:36:23
Android中ListView如何分页加载数据
2023-09-08 18:44:35
![](https://img.aspxhome.com/file/2023/5/137355_0s.jpg)
Java注解Annotation原理及自定义注解代码实例
2023-04-30 10:18:09
关于Spring中的三级缓存解析
2022-08-20 15:31:06
![](https://img.aspxhome.com/file/2023/5/122965_0s.jpg)