我有个例子,可以杀掉所有的IE.你可以参考以下:string ps="IExplore.exe";
System.Diagnostics.Process[] myProcesses = System.Diagnostics.Process.GetProcesses();
foreach(System.Diagnostics.Process myProcess in myProcesses)
{
if ("IEXPLORE"==myProcess.ProcessName)
myProcess.Kill();
}
System.Diagnostics.Process[] myProcesses = System.Diagnostics.Process.GetProcesses();
foreach(System.Diagnostics.Process myProcess in myProcesses)
{
if ("IEXPLORE"==myProcess.ProcessName)
myProcess.Kill();
}
public static void Main(string[] args)
{
Process[] myProcesses = Process.GetProcessesByName(Process.GetCurrentProcess().ProcessName);
if(myProcesses.Length<=1)
Application.Run(new MainForm());
else
{
MessageBox.Show("程序已经启动!","提示,MessageBoxButtons.OK,MessageBoxIcon.Exclamation);
Application.Exit();
}
}
brun = (UBound(Process.GetProcessesByName(Process.GetCurrentProcess.ProcessName)) > 0)
If brun = True Then
MessageBox.Show("程序已经运行,请不要打开两次!", "MAIN", MessageBoxButtons.OK, MessageBoxIcon.Stop)
Exit Sub
Application.Exit()
End if
不要打开两次