获得ie地址栏句柄(并取得其内容sendmessage) ![该帖包含图片](http://s.qun.qq.com/god/images/havepic.gif)
///
// 04TellToClose.cpp文件
链接:http://topic.csdn.net/t/20041202/13/3608704.html
#include "stdafx.h"
#include <windows.h>
int main(int argc, char* argv[])
{
// 查找标题为“无标题 - 记事本”的窗口
// 也可以使用类名来查找,如::FindWindow("Notepad", NULL);
HWND hWnd =::FindWindow("IEFrame", NULL);
HWND hWnd1=::FindWindowEx(hWnd,0,"WorkerW",NULL);
HWND hWnd2= ::FindWindowEx(hWnd1,0,"ReBarWindow32",NULL);
HWND hWnd3=::FindWindowEx(hWnd2,0,"ComboBoxEx32", NULL);
HWND hWnd4=::FindWindowEx(hWnd3,0,"ComboBox", NULL);
HWND hWnd5=::FindWindowEx(hWnd4,0,"Edit",NULL);
if(hWnd5 != NULL)
{
//调试用
MessageBox(NULL,"已获得句柄","tt",0);
// 向目标窗口发送WM_CLOSE消息
//::SendMessage(hWnd, WM_CLOSE, 0, 0);
int i=SendMessage(hWnd5,WM_GETTEXTLENGTH,0,0);
char *tem=new char[i];
SendMessage(hWnd5,WM_GETTEXT,i+1,long(tem));
printf("%s",tem);
}
else
{
MessageBox(NULL,"oo","NULL",0);
}
return 0;
}
// 04TellToClose.cpp文件
链接:http://topic.csdn.net/t/20041202/13/3608704.html
#include "stdafx.h"
#include <windows.h>
int main(int argc, char* argv[])
{
// 查找标题为“无标题 - 记事本”的窗口
// 也可以使用类名来查找,如::FindWindow("Notepad", NULL);
HWND hWnd =::FindWindow("IEFrame", NULL);
HWND hWnd1=::FindWindowEx(hWnd,0,"WorkerW",NULL);
HWND hWnd2= ::FindWindowEx(hWnd1,0,"ReBarWindow32",NULL);
HWND hWnd3=::FindWindowEx(hWnd2,0,"ComboBoxEx32", NULL);
HWND hWnd4=::FindWindowEx(hWnd3,0,"ComboBox", NULL);
HWND hWnd5=::FindWindowEx(hWnd4,0,"Edit",NULL);
if(hWnd5 != NULL)
{
//调试用
MessageBox(NULL,"已获得句柄","tt",0);
// 向目标窗口发送WM_CLOSE消息
//::SendMessage(hWnd, WM_CLOSE, 0, 0);
int i=SendMessage(hWnd5,WM_GETTEXTLENGTH,0,0);
char *tem=new char[i];
SendMessage(hWnd5,WM_GETTEXT,i+1,long(tem));
printf("%s",tem);
}
else
{
MessageBox(NULL,"oo","NULL",0);
}
return 0;
}