VB.NET中,利用API杀掉Excel进程的方法
'objExcel:Microsoft.Office.Interop.Excel对象
Private Sub KillExcel(ByVal objExcel As Object)
Try
If objExcel IsNot Nothing Then
Dim lProcessIdAddr As Integer
Dim iPID As Integer
iPID = GetWindowThreadProcessId(objExcel.Hwnd, lProcessIdAddr)
System.Diagnostics.Process.GetProcessById(lProcessIdAddr).Kill()
End If
Catch ex As Exception
End Try
End Sub
本文介绍如何在VB.NET中利用API方法来终止Excel进程,通过获取进程ID并使用System.Diagnostics.Process类实现进程的关闭。
398

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



