using 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();
}
}
}
}
有两个启动计算器的按钮,一个关闭所有计算器进程的按钮,关闭的按钮获取不到计算器的进程为什么呢