3

我想插入所有运行到列表框中的进程,
以及如何“杀死”进程并启动进程?

for i = 0 to procCount
...
next i
4

2 回答 2

8

列表+杀死:

For Each p As Process In Process.GetProcesses
    ListBox1.Items.Add(p.ProcessName.ToString)
    If String.compare(p.ProcessName, "iexplore",true) = 0 Then
        p.Kill()
    End If
Next

使用kill()杀死进程
打开进程:

Process.Start("pname.exe")
于 2012-06-19T12:18:57.020 回答
1

您还可以在以编程方式启动 Excel 之前创建一个包含所有正在运行的 Excel 进程的列表(使用 Linq 语句):

Dim lstExcelProcess As List(Of Process) = (From p As Process In Process.GetProcesses Where p.ProcessName.ToUpper Like "Excel*".ToUpper).ToList

在你完成你必须做的事情之后,杀死之前没有列出的唯一进程:

Dim process As Process = (From p As Process In process.GetProcesses Where p.ProcessName.ToUpper Like "Excel*".ToUpper And Not lstExcelProcess.Contains(p))(0)
            process.Kill()
于 2013-10-02T12:40:27.993 回答