两种思路: 1 用findwindow之类的api查找所有顶级窗口,然后根据类名或对应进程信息,判断其是否为需要的窗口,关闭时,用sendmessage发送WM_CLOSE消息即可2 枚举ShellWindows中的窗口,要关闭的时候调用quit方法即可: Option Explicit '需要引用 Microsoft Internet Controls Dim mShellWindows As New ShellWindows Private Sub Command1_Click() Dim b As InternetExplorer For Each b In mShellWindows If b.FullName = VBA.Environ$("windir") & "\explorer.exe" Then Debug.Print b.LocationName End If Next End SubPrivate Sub Command2_Click() '关闭所有符合你要求的窗口 Dim b As InternetExplorer For Each b In mShellWindows If b.FullName = VBA.Environ$("windir") & "\explorer.exe" Then b.Quit End If Next End Sub
1 用findwindow之类的api查找所有顶级窗口,然后根据类名或对应进程信息,判断其是否为需要的窗口,关闭时,用sendmessage发送WM_CLOSE消息即可2 枚举ShellWindows中的窗口,要关闭的时候调用quit方法即可:
Option Explicit
'需要引用 Microsoft Internet Controls
Dim mShellWindows As New ShellWindows
Private Sub Command1_Click()
Dim b As InternetExplorer
For Each b In mShellWindows
If b.FullName = VBA.Environ$("windir") & "\explorer.exe" Then
Debug.Print b.LocationName
End If
Next
End SubPrivate Sub Command2_Click()
'关闭所有符合你要求的窗口
Dim b As InternetExplorer
For Each b In mShellWindows
If b.FullName = VBA.Environ$("windir") & "\explorer.exe" Then
b.Quit
End If
Next
End Sub
嘎嘎,今天终于被我看到这个代码了。..............收藏