在vb中有shell这个函数来打开一个可执行文件 那么我想问一下有没有一个对应的函数那就是有没有一个函数来关闭这个可执行文件 谢谢!!!
Option Explicit
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Const WM_CLOSE = &H10
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 PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Sub Command1_Click()
Shell "calc.exe", vbNormalFocus '运行计算器
End Sub
Private Sub Command2_Click()
Dim wHwnd As Long
wHwnd = FindWindow(vbNullString, "计算器") '检查有没有运行计算器
If wHwnd <> 0 Then
PostMessage wHwnd, WM_CLOSE, 0&, 0& '发送信息关闭它
End If
End Sub