所以这是一个非常古老的帖子,但我偶然发现了它,所以我想我会尝试回答它,因为我刚学会这个:)
您可以使用Windows Shell来完成。您可以遍历打开的窗口并查找任何“HTTPDocumentClass”对象(这些是 Internet Explorer 窗口),然后您可以访问.LocationUrl成员以找出 URL。
我不知道如何用 C# 编写示例,但这是你在 VB 中的做法。
注意:您需要添加对Microsoft Shell Controls and Automation和Microsoft Internet Controls的引用。
Imports Shell32
Imports SHDocVw
Public Function GetIExplorerURL() As String()
Dim exShell As New Shell32.Shell
Dim URLs As New List(Of String)
For Each window As SHDocVw.ShellBrowserWindow In DirectCast(exShell.Windows, SHDocVw.IShellWindows)
If TypeName(window.Document) = "HTMLDocumentClass" Then
URLs.Add(window.LocationURL)
End If
Next
Return URLs.ToArray
End Function