33 lines
870 B
C#
33 lines
870 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Diagnostics;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
|
|
namespace DeleteExe
|
|
{
|
|
public partial class Form1 : Form
|
|
{
|
|
public Form1()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void button1_Click(object sender, EventArgs e)
|
|
{
|
|
Process[] processes = Process.GetProcesses(); //同程序名的所有进程
|
|
foreach (Process p in processes)//判断当前进程中是否已有该程序
|
|
{
|
|
if (p.MainModule.ModuleName.ToLower().Contains(".tmp"))//通过程序路径判断,而不能通过程序名判断
|
|
{
|
|
p.Kill(); // 结束进程
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|