Dim winHwnd As Long Dim RetVal As Long Private Declare Function FindWindow 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 Const WM_CLOSE = &H10 winHwnd = FindWindow(vbNullString, "Watch") If winHwnd <> 0 Then RetVal = PostMessage(winHwnd, WM_CLOSE, 0&, 0&) ' If RetVal = 0 Then ' MsgBox "置入消息错误!" ' End If ' Else ' MsgBox "Calculator没有打开!" End If
Dim RetVal As Long
Private Declare Function FindWindow 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
Const WM_CLOSE = &H10
winHwnd = FindWindow(vbNullString, "Watch")
If winHwnd <> 0 Then
RetVal = PostMessage(winHwnd, WM_CLOSE, 0&, 0&)
' If RetVal = 0 Then
' MsgBox "置入消息错误!"
' End If
' Else
' MsgBox "Calculator没有打开!"
End If