1个回答
展开全部
Private Declare Function FindWindows Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const WM_CLOSE = &H10
Private Sub Command1_Click()
'winhwnd = FindWindows("Windows 任务管理器", vbNullString) '知道窗口类名,关闭
winhwnd = FindWindows(vbNullString, "Microsoft Word") '知道窗口标题,关闭
Call PostMessage(winhwnd, WM_CLOSE, 0&, 0&)
End Sub
追问
我试了一下,但没能关闭指定的进程;
我编写了一个小程序,运行后,想通过另外一个程序去关闭它,这就是我的思路
追答
不管你怎么弄,都是要先获取hwnd,然后关闭它,你先搜出窗口再说吧
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询