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浏览

解决方案 »

  1.   

    hjd_cw(),可否把例子发一份给我,[email protected] 
      多谢!
      

  2.   

    广告条在主框架之下的窗口类名是Internet Explorer_Server,而弹出的IE窗口之下的确实菜单名,其类名是ToolBarWindow32.
    得到窗口句柄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下广告条 
      

  3.   

    普通的IE窗口与广告窗口的STYLE不同,可通过EnumWindowsEx获得hwnd,再通过
    GetWindowsLong(hwnd,GWL_STYLE)得到样式进行判断,具体的是什么样式可通过Spy++获得。
      

  4.   

    这个上面有很多这种文章!http://www.snowdeer.net/BBS/list.asp
      

  5.   

    My_first(海浪),怎么联系你啊?能看看你做的软件吗?
     我现在考虑用BHO来实现,但还是有问题不能解决:虽然不会误关正常的
    窗口,但有些广告窗口就无法识别了。
    能介绍一下你的方法吗?
      

  6.   

    关闭ie广告窗口
    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);