Fairy-HE
2017-12-09 12:30C#计算器的进程不能关闭
5using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Diagnostics;
using System.IO;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
process1.Start();
}
private void button2_Click(object sender, EventArgs e)
{
FileInfo file = new FileInfo(@"C:\Windows\System32\calc.exe");
if (file.Exists)
{
Process proc = new Process();
proc.StartInfo.FileName = file.FullName;
proc.Start();
}
}
private void button3_Click(object sender, EventArgs e)
{
Process[] cp;
cp = Process.GetProcessesByName("calc");
//cp = Process.GetProcessesByName("calc.exe");
int i = cp.Length;
foreach (Process instance in cp)
{
instance.Close();
}
}
}
}
有两个启动计算器的按钮,一个关闭所有计算器进程的按钮,关闭的按钮获取不到计算器的进程为什么呢
- 点赞
- 回答
- 收藏
- 复制链接分享
5条回答
为你推荐
- C#的一个应用,获取进程
- visual studio
- c#
- asp.net
- microsoft
- 1个回答
- c#事件委托 Text事件为什么不能触发呢?
- c#
- visual studio
- asp.net
- 1个回答
- C# 结构中不能有实例字段初始值设定项
- c#
- 4个回答
- C# 计算器 textbox文本框
- 控件
- 图片
- textbox
- c#
- 1个回答
- C#中关于贷款计算器的问题
- c#
- 2个回答
换一换