procedure TzypNeoForm.Timer1Timer(Sender: TObject);
//close the ad windows
var
mainHD,WorkAHD,ViewHD:THandle;
y_workA,y_view:integer;
rect1,rect2:TRect;
begin
// Kill AD.
mainHD:=FindWIndowEx(0,0,'CabinetWClass',nil);
if Mainhd<>0 then
begin
WorkAHD:=FindWindowEx(Mainhd,0,'WorkerA',nil);
GetwindowRect(WorkAHD,rect1);
y_workA:=rect1.top;
ViewHD:=FindWindowEx(mainHD,0,'Shell DocObject View',nil);
if viewHD<>0 then ////注1:
begin
GetwindowRect(ViewHD,rect2);
y_view:=rect2.top;
if y_View-y_WorkA<5 then PostMessage(Mainhd,WM_CLOSE,0,0);
end;
end;
end;
原理就是这样,具体你自己去写吧,我现在就用它自动启动进行IE浏览
//close the ad windows
var
mainHD,WorkAHD,ViewHD:THandle;
y_workA,y_view:integer;
rect1,rect2:TRect;
begin
// Kill AD.
mainHD:=FindWIndowEx(0,0,'CabinetWClass',nil);
if Mainhd<>0 then
begin
WorkAHD:=FindWindowEx(Mainhd,0,'WorkerA',nil);
GetwindowRect(WorkAHD,rect1);
y_workA:=rect1.top;
ViewHD:=FindWindowEx(mainHD,0,'Shell DocObject View',nil);
if viewHD<>0 then ////注1:
begin
GetwindowRect(ViewHD,rect2);
y_view:=rect2.top;
if y_View-y_WorkA<5 then PostMessage(Mainhd,WM_CLOSE,0,0);
end;
end;
end;
原理就是这样,具体你自己去写吧,我现在就用它自动启动进行IE浏览
解决方案 »
- delphi7用TIdHTTP写抓取指定网页时,被报有毒,有没有其它代替办法?
- qq600415接分
- 兄弟们:有没有谁了解或在 [杭州领先科技] 上班
- 如何在Delphi下利用拖拽实现文件(文件夹)的移动和复制!!!望高手指点,多谢!!!
- 过年了,散分之1
- TEdit(实现像VFP中的Init和unLoad事件)
- 关于属性如何使用?
- 将Memo中的三行数据插入表中,语句怎么写
- 其实我是想弄清楚,为什么我的字段定义成varchar了,写入数据库是也用trim 了,但存进去以后后面还是有空格,不知道为什么?
- 请问如何在memo字段中查找字符窜??
- 在com对象里用quickrep打印死机!谁能帮我一把???
- 一个AdoQury的数据记录增加问题!
多谢!
得到窗口句柄hwnd后,可以用GetClassName(hwnd,str,255)得到窗口类名。然后如下比较
if((lstrcmp(str,_T("IEFrame"))==0) && (lstrcmp(str,_T("Internet Explorer_Server"))==0) win2000下的广告条
if((lstrcmp(str,_T("CabinetWClass"))==0) && (lstrcmp(str,_t("Internet Explorer_Server"))==0) win98下广告条
GetWindowsLong(hwnd,GWL_STYLE)得到样式进行判断,具体的是什么样式可通过Spy++获得。
我现在考虑用BHO来实现,但还是有问题不能解决:虽然不会误关正常的
窗口,但有些广告窗口就无法识别了。
能介绍一下你的方法吗?
procedure TForm1.Button1Click(Sender: TObject);
var
hMain,hAdv:integer;
szAddr,szClass:pchar;
begin
szAddr:='http://sports.sina.com.cn';
shellexecute(0,'open',szaddr,0,0,SW_SHOWNORMAL);
hadv:=findwindow('CabinetWClass',0);
if hmain>0 then
closewindow(hadv);
end;
//如果你想在自己程序里集成webbrowser的话,则hadv:=findwindow('CabinetWClass',0);
应该为hadv:=findwindow('IEFRAME',0);