VB关闭程序
作者:admin 日期:2008-05-21
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
Public Const WM_CLOSE = &H10
Private Sub Form_Load()
Dim winHwnd As Long
Dim RetVal As Long
winHwnd = FindWindow(vbNullString, "迅雷5")
Debug.Print winHwnd
If winHwnd <> 0 Then
RetVal = PostMessage(winHwnd, WM_CLOSE, 0&, 0&)
If RetVal = 0 Then
MsgBox "Error posting message."
End If
Else
MsgBox "The 迅雷5 is not open."
End If
End Sub
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
Public Const WM_CLOSE = &H10
Private Sub Form_Load()
Dim winHwnd As Long
Dim RetVal As Long
winHwnd = FindWindow(vbNullString, "迅雷5")
Debug.Print winHwnd
If winHwnd <> 0 Then
RetVal = PostMessage(winHwnd, WM_CLOSE, 0&, 0&)
If RetVal = 0 Then
MsgBox "Error posting message."
End If
Else
MsgBox "The 迅雷5 is not open."
End If
End Sub
评论: 0 | 引用: 0 | 查看次数: 1590
发表评论
你没有权限发表留言!