关闭错误弹出窗口,我是用Timer来做的:
    h := findwindow(nil,'Internet Explorer 脚本错误');
    if H > 0 then
    begin
      sendmessage(H,WM_CLOSE,0,0);
    end;
findwindow(nil,'Internet Explorer 脚本错误'),必须写全'Internet Explorer 脚本错误',不对的话就行不通,那么关闭另外的IE窗口是不是也要写全呢?应该怎样做?写‘Microsoft Internet Explorer’也不行,请高手指点。

解决方案 »

  1.   

    program Project1;{$APPTYPE CONSOLE}uses
      SysUtils, Windows, Messages;function EnumWindowsProc(hWnd: HWND; lParam: LParam): Longbool; stdcall;
    var
      Buf: array[0..1023] of Char;
    begin
      Result:=true;
      FillChar(Buf, SizeOf(Buf), 0);
      GetWindowText(hWnd, @Buf, SizeOf(Buf));
      if Pos('Internet Explorer', Buf)>0 then
      begin
        SendMessage(hWnd, WM_CLOSE, 0, 0);
        Result:=false;
      end;
    end;begin
      EnumWindows(@EnumWindowsProc, 0);
      ReadLn;
    end.
      

  2.   

    谢谢你们的回复,我想请问clasj一下,GetWindowText(hWnd, @Buf, SizeOf(Buf));能够取到所有窗口的title吗?我试了一下,buf里面的数据是's','i','z','e','o','f','(','b','u','f',')',其余都是0,请你们帮帮忙,谢谢。
      

  3.   

    program Project1;{$APPTYPE CONSOLE}uses
      SysUtils, Windows, Messages;function EnumWindowsProc(hWnd: HWND; lParam: LParam): Longbool; stdcall;
    var
      Buf: array[0..1023] of Char;
    begin
      Result:=true;
      FillChar(Buf, SizeOf(Buf), 0);
      GetWindowText(hWnd, @Buf, SizeOf(Buf));
      WriteLn(Buf); //加上这一句看看<==============================================
      if Pos('Internet Explorer', Buf)>0 then
      begin
        SendMessage(hWnd, WM_CLOSE, 0, 0);
        Result:=false;
      end;
    end;begin
      EnumWindows(@EnumWindowsProc, 0);
      ReadLn;
    end.
      

  4.   

    加上WriteLn(Buf); 之后出错,没有这一句运行是正确的,但@Buf里面全是#0,谢谢您。
      

  5.   

    读不到运行程序的title,如果能够读到就成功了