前端之家收集整理的这篇文章主要介绍了
VB获取IE8/IE9地址栏URL,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
参考:答疑网
http://www.dayi.net
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 String) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long,ByVal wMsg As Long,ByVal wParam As Long,lParam As Long) As Long
Private Declare Function SendMessageByString Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long,ByVal lParam As String) As Long
Private Const WM_GETTEXTLENGTH = &HE
Private Const WM_GETTEXT = &HD
Private Sub Command1_Click()
Dim hwnd As Long
Dim retLength As Long,retString As String
hwnd = FindWindowEx(0,"IEFrame",vbNullString)
hwnd = FindWindowEx(hwnd,"WorkerW","ReBarWindow32","Address Band Root","Edit",vbNullString)
retLength = SendMessage(hwnd,WM_GETTEXTLENGTH,0)
retString = String(retLength,0)
SendMessageByString hwnd,WM_GETTEXT,retLength + 1,retString
MsgBox retString
End Sub