Private Const WM_CLOSE = &H10 Public Function CloseSpecWindow(ByVal WndTitle As String) As Boolean Dim Rtn& Dim hwnd As Long If WndTitle = "" Then GoTo Close_Error hwnd = FindWindow(vbNullString, WndTitle) If hwnd <= 0 Then GoTo Close_Error Rtn = SendMessage(hwnd, WM_CLOSE, 0, ByVal 0&) CloseSpecWindow = Rtn Exit Function Close_Error: CloseSpecWindow = False End Function 这是利用窗口title来close窗口的函数
然后用sendmessage向他发送WM_CLOSE消息,或用closewindow关闭这个窗口.
Public Function CloseSpecWindow(ByVal WndTitle As String) As Boolean
Dim Rtn&
Dim hwnd As Long If WndTitle = "" Then GoTo Close_Error
hwnd = FindWindow(vbNullString, WndTitle)
If hwnd <= 0 Then GoTo Close_Error
Rtn = SendMessage(hwnd, WM_CLOSE, 0, ByVal 0&)
CloseSpecWindow = Rtn
Exit Function
Close_Error:
CloseSpecWindow = False
End Function
这是利用窗口title来close窗口的函数