用vb6打开一个IE浏览器窗口打开一网址,怎么监视其地址栏的变化
用vb6打开一个IE浏览器窗口打开一网址,怎么监视其地址栏的变化谢谢。。 用“BHO”接口。
可以用webbrowser
Option Explicit
Private Sub Form_Load()
'需要引用Microsoft Internet Controls对象
Dim WebCount As SHDocVw.ShellWindows
Dim tmpI As Long, tmpWeb As WebBrowser
Set WebCount = New SHDocVw.ShellWindows
MsgBox "已经打开" & WebCount.Count & "个网页"
For tmpI = 0 To WebCount.Count - 1
Set tmpWeb = WebCount.Item(tmpI)
Debug.Print tmpWeb.LocationURL
Debug.Print tmpWeb.LocationName
Next
Set tmpWeb = Nothing
End Sub
参考:
http://www.m5home.com/bak_blog/article/181.html 读 IE 地址栏内容:
Option Explicit用webbrowser对象。 用ie的话:BHO更能太强大。对网页内部的元素都可以操作。
'Reference to Microsoft Internet Control
Dim WinIE As New ShellWindows
Private Sub Command1_Click()
Dim i As Integer
List1.Clear
For i = 0 To WinIE.Count - 1
List1.AddItem WinIE.Item(i).LocationURL
Next i
End Sub
Private Sub Form_Unload(Cancel As Integer)
Set WinIE = Nothing
End Sub
网上后BHO的代码,可以下载慢慢调试。
用其他浏览器,比如谷歌的,可以自己开发浏览器插件,也比较容易
用监视窗口的办法也可以。
补充:VB , API