VB获取浏览器地址

来源:百度知道 编辑:UC知道 时间:2024/06/03 22:59:43
编写一个VB程序,用来获取IE当前的地址,怎样才能做到??VB程序里有一个按钮Command1和一个文本Text1,比如现在IE打开的是QQ的首页(http://www.qq.com),我想一点击按钮Text1就能显示到IE当前的地址!!请高手们说说!
什么控件啊》??详细说一说做法!!

'引用Microsoft Internet Controls
'添加listbox
'列出所有IE窗口的地址,要达到你要的效果,变通一下就OK

Dim dWinFolder As New ShellWindows

Private Sub Form_Load()

Dim objIE As Object

For Each objIE In dWinFolder

If 0 Or InStr(1, objIE.FullName, "IEXPLORE.EXE", vbTextCompare) <> 0 Then

List1.AddItem objIE.LocationURL

End If

Next

End Sub

一个控件

Dim oShellApp, oShellAppWindows, oWin
Set oShellApp = CreateObject("Shell.Application")
Set oShellAppWindows = oShellApp.Windows
For Each oWin In oShellAppWindows
If LCase(TypeName(oWin.document)) = "htmldocument" Then
text1.text= oWin.LocationURL
enf if
Next
Set oWin = Nothing
Set oShellApp = Nothing
Set oShellAppWindows = Nothing

给你个思路吧。1.获取所有ie窗口
2.对每一个窗口,搜索地址栏类型的子窗口
3.判断是否以http://开头的,如果是则获取

我现在没有vb的api浏览器,也