var
SLWindowCaption, SLWindowHeight, SLWindowWidth: TStringList;
ShellWindow: IShellWindows;
OV: OleVariant;
spDisp: IDispatch;
IHD: IHTMLDocument2;
J, SWCount: integer;
IWB: IWebBrowser2;
begin
SLWindowHeight := TStringList.Create;
SLWindowWidth := TStringList.Create;
ShellWindow := CoShellWindows.Create;
SWCount := ShellWindow.Count;
for J := 0 to SWCount - 1 do
begin
OV := J;
spDisp := ShellWindow.Item(OV);
spDisp.QueryInterface( iWebBrowser2, IWB);
if IWB <> nil then
begin
SLWindowHeight.Add(IntToStr(IWB.Height));
SLWindowWidth.Add(IntToStr(IWB.Width));
IWB.Document.QueryInterface(IHTMLDocument2, IHD);
Memo1.lines.Add(IWB.LocationURL);
if IHD <> nil then
begin
if (IWB.Height <= 300) and (IWB.Width <= 400) then
PostMessage(IWB.HWND, WM_CLOSE, 0, 0);
end;
end;
end;
上面的代码不知道出了什么问题。
只要一有新的弹出窗口,他就抱错。
什么:“未指定的错误”“不支持该类窗口”等等~~乱七八糟的。
然后还关闭掉一些正常的IE窗口。
大家帮忙解决以下萨~~求求了~`谢谢`~
SLWindowCaption, SLWindowHeight, SLWindowWidth: TStringList;
ShellWindow: IShellWindows;
OV: OleVariant;
spDisp: IDispatch;
IHD: IHTMLDocument2;
J, SWCount: integer;
IWB: IWebBrowser2;
begin
SLWindowHeight := TStringList.Create;
SLWindowWidth := TStringList.Create;
ShellWindow := CoShellWindows.Create;
SWCount := ShellWindow.Count;
for J := 0 to SWCount - 1 do
begin
OV := J;
spDisp := ShellWindow.Item(OV);
spDisp.QueryInterface( iWebBrowser2, IWB);
if IWB <> nil then
begin
SLWindowHeight.Add(IntToStr(IWB.Height));
SLWindowWidth.Add(IntToStr(IWB.Width));
IWB.Document.QueryInterface(IHTMLDocument2, IHD);
Memo1.lines.Add(IWB.LocationURL);
if IHD <> nil then
begin
if (IWB.Height <= 300) and (IWB.Width <= 400) then
PostMessage(IWB.HWND, WM_CLOSE, 0, 0);
end;
end;
end;
上面的代码不知道出了什么问题。
只要一有新的弹出窗口,他就抱错。
什么:“未指定的错误”“不支持该类窗口”等等~~乱七八糟的。
然后还关闭掉一些正常的IE窗口。
大家帮忙解决以下萨~~求求了~`谢谢`~
file:///::%7BE17D4FC0-5564-11D1-83F2-*********(隐藏起来,不给你看)
file:///::%7BE17D4FC0-5564-11D1-83F2-*********(隐藏起来,不给你看)
如果你放在timer里定时触发就会出错~~
如果时间长度长一些就会错误少一些~!~~`
怎么回事?
except
end;
包一下
你这代码从哪弄来的我好象见过 :)