VB已知进程名,以及进程路径,获取pid,然后结束进程
如题,进程名和系统某程序相同的,如果只判断进程名恐怕会结束错。所以希望可以通过路径判断是否存在。...
如题,进程名和系统某程序相同的,如果只判断进程名恐怕会结束错。所以希望可以通过路径判断 是否存在。
展开
1个回答
展开全部
Option Explicit
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function TerminateProcess Lib "kernel32" (ByVal hProcess As Long, ByVal uExitCode As Long) As Long
Const WM_CLOSE = &H10
Public Function EndOld(WindowName As String)
Dim app_hWnd As Long
app_hWnd = FindWindow(vbNullString, WindowName)
If app_hWnd <> 0 Then
SendMessage app_hWnd, WM_CLOSE, 0, 0
TerminateProcess app_hWnd, 0
End If
End Function
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function TerminateProcess Lib "kernel32" (ByVal hProcess As Long, ByVal uExitCode As Long) As Long
Const WM_CLOSE = &H10
Public Function EndOld(WindowName As String)
Dim app_hWnd As Long
app_hWnd = FindWindow(vbNullString, WindowName)
If app_hWnd <> 0 Then
SendMessage app_hWnd, WM_CLOSE, 0, 0
TerminateProcess app_hWnd, 0
End If
End Function
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询