T
tengzhenln
Unregistered / Unconfirmed
GUEST, unregistred user!
<br>我写的<br>function GetIeUrl():string; <br>var <br>hWorker,hRebar,hComEx,hcom,hEdit, hwndParent:hwnd; <br>szUrl: string; <br><br>begin <br>hwndParent:=FindWindow('IEFrame',nil); <br>if hwndparent=0 then result:='0'; <br>begin <br>hWorker:=FindWindowEx(hwndParent,0,'WorkerA',nil); <br>if hworker=0 then <br>begin <br>hWorker:=FindWindowEx(hwndParent,0,'WorkerW',nil); <br> hRebar:=FindWindowEx(hWorker,0,'ReBarWindow32',nil); <br> hComEx:=FindWindowEx(hRebar,0,'ComboBoxEx32',nil); <br> hcom:=FindWindowEx(hComEx,0,'ComboBox',nil); <br> hEdit:=FindWindowEx(hcom,0,'Edit',nil); <br>SendMessage(hEdit,WM_GETTEXT,260,LPARAM(szUrl)); <br> result:=szurl; <br>end; <br>end; <br>end; <br>procedure TForm1.Timer1Timer(Sender: TObject); <br>var <br>s:string; <br>begin <br> s:=GetIeUrl(); <br> edit1.text:=GetIeUrl(); <br> if s<>0 then <br> begin <br> if s='XXXX' then <br> begin <br> Application.MessageBox(‘上黄色网站','让我知道了吧。',MB_ICONINFORMATION+MB_OK) ; <br> end; <br> end; <br>end; <br><br>源程序<br><br>CString GetIeUrl() <br>{ HWND hWorker,hRebar,hComEx,hcom,hEdit; <br> HWND hwndParent=::FindWindow("IEFrame",NULL);//只找最近的IE(active) <br> if(hwndParent == NULL) <br> return FALSE; <br> char szUrl[260]; <br> hWorker=FindWindowEx(hwndParent,0,"WorkerA",NULL); <br> if(hWorker == NULL) <br> hWorker=FindWindowEx(hwndParent,0,"WorkerW",NULL); <br> hRebar=FindWindowEx(hWorker,0,"ReBarWindow32",NULL); <br> hComEx=FindWindowEx(hRebar,0,"ComboBoxEx32",NULL); <br> hcom=FindWindowEx(hComEx,0,"ComboBox",NULL); <br> hEdit=FindWindowEx(hcom,0,"Edit",NULL); <br> ::SendMessage(hEdit,WM_GETTEXT,260,(LPARAM) szUrl); <br> return szUrl; <br>} <br><br>添加WM_TIMER <br>CyouDlg::OnTimer(UNIT nEvent) <br>{ <br> CStirng s; <br> s=GetIeUrl(); <br> if(s!==NULL) <br> { <br> //做你的处理 <br> if(!strstr((char *)s,"sex")) <br> {MesageBox("ha 你在看黄色网站 这可不好","Warnning");} <br> } <br>} <br><br>