1,488
社区成员




Option Explicit
Private Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, _
ByVal lpString As String, ByVal cch As Long) As Long
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 Const WM_SYSCOMMAND = &H112
Private Const SC_CLOSE = &HF060&
Sub main()
EnumWindows AddressOf EnumWindowsProc, 0
End Sub
Private Function EnumWindowsProc(ByVal hwnd As Long, ByVal lParam As Long) As Long
Dim strCaption As String
strCaption = String(255, vbNullChar)
GetWindowText hwnd, strCaption, 255 '获得窗口标题
strCaption = Left(strCaption, InStr(strCaption, vbNullChar) - 1)
If InStr(strCaption, "hao123") Then '判断标题中是否包含hao123网址之家
SendMessage hwnd, WM_SYSCOMMAND, SC_CLOSE, 0&
End If
EnumWindowsProc = 1 '继续查找下一个窗口
End Function