Private Sub KillProcess(ByVal processName As String) '杀进程代码
Dim myproc As System.Diagnostics.Process = New System.Diagnostics.Process
Try
For Each thisproc As Process In Process.GetProcessesByName(processName)
If (Not thisproc.CloseMainWindow()) Then
thisproc.Kill()
End If
Next
Catch
End Try
End Sub
Dim myproc As System.Diagnostics.Process = New System.Diagnostics.Process
Try
For Each thisproc As Process In Process.GetProcessesByName(processName)
If (Not thisproc.CloseMainWindow()) Then
thisproc.Kill()
End If
Next
Catch
End Try
End Sub
本文提供了一个使用 VB.NET 编写的简单示例,展示了如何终止指定名称的进程。通过遍历并查找匹配的进程名称,如果找到则尝试关闭主窗口,若失败则直接结束进程。
2138

被折叠的 条评论
为什么被折叠?



