如何在VB应用程序下关闭其它运行的Windows程序 如果你想用自己的程序关闭正在运行的Windows其它程序，可用以下代码来实现。 首先声明两个函数: Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long 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
例如要检测“计算器”程序是否正在运行，如果是则关闭它，可以使用如下代码来实现:
Dim winHwnd As Long
Dim RetVal As Long
winHwnd=FindWindow(vbNullString,"计算器")
If winHwnd〈〉0 Then
RetVal = PostMessage(winHwnd, &&H10, 0&&, 0&&)
If RetVal = 0 Then
MsgBox "关闭计算器出错!"
End If
Else
MsgBox "计算器程序没有运行。"
End If

(何佳)