求帮助 不知道怎么改
using System;using System.Collections.Generic;
using
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
namespace _6._2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
listBox1.Items.Clear();
Process[] allProcess = Process.GetProcesses();
foreach(Process myProcess in allProcess ){
listBox1.Items.Add("进程: " + myProcess.ProcessName + "的ID为:" + Convert.ToString(myProcess.Id ));
}
}
private void button2_Click(object sender, EventArgs e)
{
Process myprocess = new Process();
ProcessStartInfo startInfo = new ProcessStartInfo(Application.StartupPath+"\\NOTEPAD.exe");
startInfo.WindowStyle = ProcessWindowStyle.Normal;
startInfo.WorkingDirectory = Application.StartupPath;
myprocess.StartInfo = startInfo;
myprocess.StartInfo.UseShellExecute = false;
myprocess.Start();
Process current = Process.GetCurrentProcess();
current.CloseMainWindow();
}
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
if (MessageBox.Show("真的要退出系统吗?", "进程测试程序",
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
e.Cancle = false;
else
e.Cancle = true;
}
}
}