【发布时间】:2011-07-03 18:47:49
【问题描述】:
我正在尝试创建一个小型生产力程序,以使自己在编程时保持专注;具体来说,关闭任何可能分散我工作注意力的流程。为简单起见,我在 VB.NET 中编写它。
杀死列表框中列出的所有进程的最简单方法是什么?我已经知道如何使用以下代码将进程添加到我的列表框中:
Dim newProc As New OpenFileDialog
'// Settings for the open file dialog. (I like how I use ' to start the comment, but // so I recognize it! :)
newProc.Filter = "Executable files (*.exe)|*.exe"
newProc.FileName = "..choose a file.."
newProc.Multiselect = True
newProc.CheckFileExists = True
newProc.CheckPathExists = True
newProc.AutoUpgradeEnabled = True
newProc.AddExtension = True
If (newProc.ShowDialog = Windows.Forms.DialogResult.OK) Then
ListBox1.Items.AddRange(newProc.SafeFileNames)
End If
这将非常整齐地添加到列表框中的进程,这正是我想要的。我有一个计时器可以通过按下一个按钮来启用,该按钮应该关闭列表框中的所有进程,但我不确定我应该使用什么。我能得到一些帮助吗? :(
【问题讨论】:
标签: vb.net process listbox kill