Наши проекты:
Журнал · Discuz!ML · Wiki · DRKB · Помощь проекту |
||
ПРАВИЛА | FAQ | Помощь | Поиск | Участники | Календарь | Избранное | RSS |
[13.58.247.31] |
|
Сообщ.
#1
,
|
|
|
сабж.
|
Сообщ.
#2
,
|
|
|
Воть. Эксперементировал как-то.
#include "stdafx.h" #include <stdio.h> char sbuf[256]=""; char sbuf2[256]=""; char cmdline[]="explore"; char Buf[25600]=""; char * pstr=NULL; DWORD ProcessId=0,ThreadId=0; DWORD MyPid=0; HWND MyHwnd=0; char* GetUrl(HWND hwnd) { char Class[260]=""; char sbuf[260]=""; int Len=0; char *url=NULL; HWND ie,toolbar,combo,comboboxex,edit,worker,toolbarwindow; LPARAM lParam=NULL; //ie=FindWindow("IEFrame",NULL); if(GetClassName(hwnd,Class,sizeof(Class))) { if(!strcmp(Class,"IEFrame")) { worker=FindWindowEx(hwnd,0,"WorkerW",NULL); if(worker) { toolbar=FindWindowEx(worker,0,"ReBarWindow32",NULL); if(toolbar) { comboboxex=FindWindowEx(toolbar,0,"ComboBoxEx32",NULL); if(comboboxex) { //edit=comboboxex; combo=FindWindowEx(comboboxex,0,"ComboBox",NULL); if(combo) { Beep(1000,50); edit=FindWindowEx(combo,0,"Edit",NULL); if(edit) { //toolbarwindow=FindWindowEx(comboboxex,0,"ToolBarWindow32",NULL); Len=SendMessage(edit,WM_GETTEXTLENGTH,0,lParam); url = new char [Len+1]="\0"; //SendMessage(edit,WM_GETTEXT,Len,(LPARAM)url); sprintf(sbuf,"Len : %d",Len); SendMessage(edit,WM_GETTEXT,260,(LPARAM)url); //if(strlen(sbuf)>0) MessageBox(0,sbuf,"sbuf",0); //MessageBox(0,sbuf,"sbuf",0); MessageBox(0,url,sbuf,0); SendMessage(edit,WM_SETTEXT,0,(LPARAM)"MyAddress"); //if(strlen(url)>0) MessageBox(0,url,sbuf,0); //else if(GetWindowText(combo,sbuf,sizeof(sbuf))) MessageBox(0,sbuf,"GetWindowText",0); delete [] url; } } } } } } } return url; } BOOL CALLBACK FindWindows(HWND hwnd,LPARAM lParam) { GetWindowText(hwnd,sbuf,256); strlwr(sbuf); //if(strstr(sbuf,cmdline)) if(strstr(sbuf,cmdline)) { if(strlen(sbuf)>0) { ThreadId=GetWindowThreadProcessId(hwnd,&ProcessId); sprintf(sbuf2,"WindowText: %s\nThreadId: %d\nProcessId: %d\nURL: %s\n\n",sbuf,ThreadId,ProcessId,GetUrl(hwnd)); strcat(Buf,sbuf2); } } return TRUE; } BOOL CALLBACK FindMyWindow(HWND hwnd,LPARAM lParam) { DWORD ProcessId=0; GetWindowThreadProcessId(hwnd,&ProcessId); if(ProcessId==MyPid) MyHwnd=hwnd; return TRUE; } int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { //sscanf(lpCmdLine,"%s",cmdline); //strncpy(cmdline,lpCmdLine,strlen(lpCmdLine)); EnumWindows(FindWindows,0); MessageBox(0,Buf,"IE Windows",0); return 0; } У меня работает под XP. Дело в том, что под 98, 2000-ю надо проверить, эксперементировать надо, подобрать оптимальный вариант. |
Сообщ.
#3
,
|
|
|
Спасибо за пример буду разбиратся.
|
Сообщ.
#4
,
|
|
|
IWebBrowser2::AddressBar
HRESULT IWebBrowser2::get_AddressBar(VARIANT_BOOL *pValue); HRESULT IWebBrowser2::put_AddressBar(VARIANT_BOOL Value); Если хочешь, то могу набросать пример... И без всяких FindWindow, а через IE'шные интерфейсы. Добавлено Каюсь немного не то! (факир был пьян и фокус не удался...) Найду напишу... |