sgnaw ( 李逍遥 )
分 IE7 及 IE6 这两种情况 .
在 IE7 中这样获取地址栏中的 URL, 其中 strAdd 即为所求:
HWND hIE
=
NULL, hWorker
=
NULL, hBar
=
NULL, hComboBox
=
NULL;
![](https://i-blog.csdnimg.cn/blog_migrate/a41954a27d6ad96fa2c2cf816e677448.gif)
TCHAR
strAdd[
256
]
=
...
{0}
;
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
hIE
=
FindWindow(_T(
"
IEFrame
"
), NULL);
if
(hIE)
hWorker
=
FindWindowEx(hIE,
0
, _T(
"
WorkerW
"
), NULL);
if
(hWorker)
hBar
=
FindWindowEx(hWorker,
0
, _T(
"
ReBarWindow32
"
), NULL);
if
(hBar)
![](https://i-blog.csdnimg.cn/blog_migrate/a41954a27d6ad96fa2c2cf816e677448.gif)
...
{
HWND hAddress = FindWindowEx(hBar, 0, _T("Address Band Root"), NULL);
HWND hComboBox = FindWindowEx(hAddress, 0, _T("ComboBoxEx32"), NULL);
SendMessage(hComboBox, WM_GETTEXT, 255, (LPARAM)strAdd);
}
在 IE6 中这样获取地址栏中的 URL, 其中 strAdd 即为所求:
HWND hIE
=
NULL, hWorker
=
NULL, hBar
=
NULL, hComboBox
=
NULL;
![](https://i-blog.csdnimg.cn/blog_migrate/a41954a27d6ad96fa2c2cf816e677448.gif)
TCHAR strAdd[
256
]
=
...
{0}
;
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
hIE
=
FindWindow(_T(
"
IEFrame
"
), NULL);
if
(hIE)
hWorker
=
FindWindowEx(hIE,
0
, _T(
"
WorkerW
"
), NULL);
if
(hWorker)
hBar
=
FindWindowEx(hWorker,
0
, _T(
"
ReBarWindow32
"
), NULL);
if
(hBar)
![](https://i-blog.csdnimg.cn/blog_migrate/a41954a27d6ad96fa2c2cf816e677448.gif)
...
{
HWND hComboBox = FindWindowEx(hBar, 0, _T("ComboBoxEx32"), NULL);
SendMessage(hComboBox, WM_GETTEXT, 255, (LPARAM)strAdd);
}