using System;
using System.Diagnostics;
using System.Windows.Forms;
namespace Process组件
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
this.Load+=new EventHandler(Form1_Load);
this.button1.Click+=new EventHandler(button1_Click);
this.button2.Click+=new EventHandler(button2_Click);
}
private void Form1_Load(object sender, EventArgs e)
{
process1.StartInfo.FileName = "notepad.exe";
}
private void button1_Click(object sender, EventArgs e)
{
process1.Start();
}
private void button2_Click(object sender, EventArgs e)
{
Process[] parr = Process.GetProcessesByName("Notepad");
foreach (Process p in parr)
{
p.CloseMainWindow();
p.WaitForExit(3000);
p.Close();
}
}
}
}
Process组件的使用
最新推荐文章于 2023-10-30 10:13:19 发布