1 void getURL() 2 { 3 HWND hWnd, hWnd1, hWnd2, hWnd3, hWnd4; 4 WCHAR URL[1000] = { 0 }; 5 hWnd = FindWindow(L"IEFrame", NULL); 6 hWnd1 = FindWindowEx(hWnd, 0, L"WorkerW", NULL); 7 hWnd2 = FindWindowEx(hWnd1, 0, L"ReBarWindow32", NULL); 8 hWnd3 = FindWindowEx(hWnd2, 0, L"Address Band Root", NULL); //获得IE窗口地址栏句柄 9 hWnd4 = FindWindowEx(hWnd3, 0, L"Edit", NULL); //获得IE窗口地址栏编辑框句柄 10 11 if (hWnd4 != NULL) 12 { 13 int i = SendMessage(hWnd4, WM_GETTEXTLENGTH, 0, 0); //向IE窗口地址栏编辑框发送获取字符串长度的命令 14 memset(URL, 0, 1000); 15 SendMessage(hWnd4, WM_GETTEXT, i + 1, long(URL)); //向IE窗口地址栏编辑框发送获取字符的命令 16 printf("%ws ", URL); 17 return; 18 } 19 else 20 { 21 printf("Don't find IE! "); 22 } 23 return; 24 }