一个VC写的屏蔽黄公网站的程序,我写成DELPHI版的就不能用了,请帮助调试。(200分)

  • 主题发起人 主题发起人 tengzhenln
  • 开始时间 开始时间
T

tengzhenln

Unregistered / Unconfirmed
GUEST, unregistred user!
<br>我写的<br>function &nbsp;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>&nbsp; &nbsp;hRebar:=FindWindowEx(hWorker,0,'ReBarWindow32',nil); <br>&nbsp; &nbsp;hComEx:=FindWindowEx(hRebar,0,'ComboBoxEx32',nil); <br>&nbsp; &nbsp;hcom:=FindWindowEx(hComEx,0,'ComboBox',nil); <br>&nbsp; &nbsp;hEdit:=FindWindowEx(hcom,0,'Edit',nil); <br>SendMessage(hEdit,WM_GETTEXT,260,LPARAM(szUrl)); <br>&nbsp; &nbsp; &nbsp;result:=szurl; <br>end; <br>end; <br>end; <br>procedure TForm1.Timer1Timer(Sender: TObject); <br>var <br>s:string; <br>begin <br>&nbsp; s:=GetIeUrl(); <br>&nbsp; edit1.text:=GetIeUrl(); <br>&nbsp; if s&lt;&gt;0 &nbsp; then <br>&nbsp; begin <br>&nbsp; if s='XXXX' then <br>&nbsp; begin <br>&nbsp; Application.MessageBox(‘上黄色网站','让我知道了吧。',MB_ICONINFORMATION+MB_OK) ; <br>&nbsp; end; <br>&nbsp; end; <br>end; <br><br>源程序<br><br>CString GetIeUrl() <br>{ &nbsp; HWND hWorker,hRebar,hComEx,hcom,hEdit; <br>&nbsp; &nbsp; HWND hwndParent=::FindWindow("IEFrame",NULL);//只找最近的IE(active) <br>&nbsp; if(hwndParent == NULL) <br>&nbsp; &nbsp; &nbsp; &nbsp; return FALSE; <br>&nbsp; &nbsp;char szUrl[260]; <br>&nbsp; &nbsp;hWorker=FindWindowEx(hwndParent,0,"WorkerA",NULL); <br>&nbsp; &nbsp;if(hWorker == NULL) <br>&nbsp; &nbsp;hWorker=FindWindowEx(hwndParent,0,"WorkerW",NULL); <br>&nbsp; &nbsp;hRebar=FindWindowEx(hWorker,0,"ReBarWindow32",NULL); <br>&nbsp; &nbsp;hComEx=FindWindowEx(hRebar,0,"ComboBoxEx32",NULL); <br>&nbsp; &nbsp;hcom=FindWindowEx(hComEx,0,"ComboBox",NULL); <br>&nbsp; &nbsp;hEdit=FindWindowEx(hcom,0,"Edit",NULL); <br>&nbsp; &nbsp;::SendMessage(hEdit,WM_GETTEXT,260,(LPARAM) szUrl); <br>&nbsp; &nbsp; return szUrl; <br>} <br><br>添加WM_TIMER <br>CyouDlg::OnTimer(UNIT nEvent) <br>{ <br>&nbsp; CStirng s; <br>&nbsp; s=GetIeUrl(); <br>&nbsp; if(s!==NULL) <br>&nbsp; &nbsp;{ <br>&nbsp; &nbsp; &nbsp;//做你的处理 <br>&nbsp; &nbsp; &nbsp;if(!strstr((char *)s,"sex")) <br>&nbsp; &nbsp; &nbsp; {MesageBox("ha 你在看黄色网站 这可不好","Warnning");} <br>&nbsp; &nbsp;} <br>} <br><br>
 
vc<br>strstr的作用是找子串<br>if(!strstr((char *)s,"sex")) <br>代表子串带有'sex'就符合条件 &nbsp; &nbsp; &nbsp;<br><br>delphi<br>if s='XXXX' then <br>代表要完全符合才行<br><br>
 
此方法只能屏蔽ie的,且不全,以下的可能好一些:<br>procedure TForm1.Timer1Timer(Sender: TObject);<br>var<br>&nbsp;fwnd:thandle;<br>&nbsp;buf2,buf:array[0..250] of char;<br>begin<br>&nbsp; fwnd:=GetForegroundWindow;<br>&nbsp; Getclassname(fwnd,buf,sizeof(buf));<br>&nbsp; Getwindowtext(fwnd,buf2,sizeof(buf2));<br>if (strpas(buf)='CabinetWClass') or (strpas(buf)='IEFrame') or (pos('Netscape',strpas(buf2))&gt;0) or (pos('Opera',strpas(buf2))&gt;0) or (pos('Tencent',strpas(buf2))&gt;0) then<br>&nbsp; &nbsp; EnumChildWindows(fwnd,@enumchildproc,0);<br>end;<br><br>function filter(url:pchar):boolean;<br>var i:integer;<br>s:string;<br>begin<br>&nbsp; result:=false;<br>&nbsp; s:=lowercase(strpas(url));<br>&nbsp; with form1.filterkeys do //设置过滤关键字列表(可以用listbox)<br>&nbsp; for i:=0 to items.count -1 do<br>&nbsp; if pos(items,s)&gt;0 then &nbsp;//比较网址URL中有没有过滤关键字列表中的字<br>&nbsp; begin<br>&nbsp; &nbsp;result:=true;<br>&nbsp; &nbsp;exit;<br>&nbsp; end;<br>end;<br>&nbsp;<br>&nbsp;function EnumChildProc(<br>&nbsp; hwnd:HWND;<br>&nbsp; IParam:LPARAM<br>&nbsp; ):bool;stdcall;<br>&nbsp; var buf:array[0..250] of char;<br>&nbsp; rsize:integer;<br>begin<br>&nbsp; result:=true;<br>&nbsp; Getclassname(hwnd,buf,sizeof(buf));<br>&nbsp;if strpas(buf)='Edit' then<br>&nbsp; begin<br>&nbsp; &nbsp; &nbsp;rsize:=sendmessage(hwnd,WM_GETTEXT,sizeof(buf),integer(@buf));<br>&nbsp; &nbsp; &nbsp;if rsize&gt;0 then<br>&nbsp; &nbsp; &nbsp;if strpas(buf)&lt;&gt;www.sohu.com then<br>&nbsp; &nbsp; &nbsp; if filter(buf) then<br>&nbsp; &nbsp; &nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp; &nbsp; sendmessage(hwnd,WM_SETTEXT,0,integer(www.sohu.com));<br>&nbsp; &nbsp; &nbsp; &nbsp; postmessage(hwnd,WM_KEYDOWN,$D,$1c0001);<br>&nbsp; &nbsp; &nbsp; &nbsp; postmessage(hwnd,WM_KEYUP,$D,$1c0001);<br>&nbsp; &nbsp; &nbsp; &nbsp;end;<br>&nbsp; &nbsp;result:=false;<br>&nbsp;end;<br>&nbsp; &nbsp;end;
 
继续!<br>
 
www.sohu.com是什么阿。字符串还是数组阿。
 
如果url里面没有sex之类的字符呢,如果想判断这个页面的内容或者图象呢?
 
同意zj1978的意见
 
○○○○○
 
都被你屏蔽掉了,某些网民还看什么?
 
就是就是,,,根本就没有应用前景。。<br>还不如编一个上过黄色网站能即时清除的 不留痕迹的软件,,,<br>折能解决很多网吧老板的问题。。。。<br>也能解决很多父母与子女之间的尴尬。。。。<br>
 
这也太简单了,98下和2000不一样!'WorkerW'是2000下了,支持UNiCODE,98下多半是<br><br>'WorkerA',熟悉Win32的朋友都知道!这样处理未免太简单了!<br><br><br>呵呵!再不用spy++看看,无非就是句柄没得到而已!
 
后退
顶部