这样够具体了吧Option Explicit Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As Long) As Long Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As LongPrivate Const WM_CLOSE = &H10Private Sub Command1_Click() Call FindAndCloseIEWindows End SubFunction FindAndCloseIEWindows() Dim hWndPre As Long Dim hWndNow As Long hWndNow = FindWindowEx(0, 0, "IEFrame", 0&) Do While hWndNow <> 0 hWndNow = FindWindowEx(0, hWndPre, "IEFrame", 0&) CloseWindow hWndPre hWndPre = hWndNow Loop End FunctionFunction CloseWindow(ByVal hWndTarget As Long) As Long CloseWindow = PostMessage(hWndTarget, WM_CLOSE, 0&, 0&) End Function
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As Long) As Long
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As LongPrivate Const WM_CLOSE = &H10Private Sub Command1_Click()
Call FindAndCloseIEWindows
End SubFunction FindAndCloseIEWindows()
Dim hWndPre As Long
Dim hWndNow As Long
hWndNow = FindWindowEx(0, 0, "IEFrame", 0&)
Do While hWndNow <> 0
hWndNow = FindWindowEx(0, hWndPre, "IEFrame", 0&)
CloseWindow hWndPre
hWndPre = hWndNow
Loop
End FunctionFunction CloseWindow(ByVal hWndTarget As Long) As Long
CloseWindow = PostMessage(hWndTarget, WM_CLOSE, 0&, 0&)
End Function