刀
刀锋战士
Unregistered / Unconfirmed
GUEST, unregistred user!
下面一段程序:
var
ShellWindow: IShellWindows;
nCount: integer;
spDisp: IDispatch;
i,j: integer;
vi,VJ,vm: OleVariant;
IE1: IWebBrowser2;
IDoc1: IHTMLDocument2;
HtmlFrame : IHTMLFramesCollection2;
HtmlWin : IHTMLWindow2;
sh:string;
begin
ShellWindow := CoShellWindows.Create;
nCount := ShellWindow.Count;
for i := 0 to nCount - 1 do
begin
vi := i;
spDisp := ShellWindow.Item(vi);
if spDisp = nil then continue;
spDisp.QueryInterface( iWebBrowser2, IE1 );
if IE1 <> nil then
begin
IE1.Document.QueryInterface(IHTMLDocument2,iDoc1);
if iDoc1 <> nil then
begin
HtmlFrame := idoc1.Get_frames;
for j:=0 to HtmlFrame.length-1 do
begin
Application.ProcessMessages;
vj:=j;
spDisp := HtmlFrame.item(vj);
if SUCCEEDED(spDisp.QueryInterface(IHTMLWindow2 ,HtmlWin))then
begin
begin
if (HtmlWin.name=form1.sfn.Text) or (form1.sfn.Text='ALL') then
begin
vm:=1;
if SUCCEEDED(HtmlWin.document.QueryInterface(IHTMLDocument2 ,IDoc1))then
begin
vj:=IDoc1.Get_all.item(0,0);
if cb.Checked then
begin
Memo2.Lines.Add('窗:'+HtmlWin.name);
Memo2.Lines.Add(vj.innerhtml); //这里是frame的网页代码啦
end;
sh:=vj.innerhtml;
Form1.hitsg(sh);
end;
end;
end;
end;
end;
Exit; //我只对第一个ie窗口使用,所以就退出
end;
end;
end;
end;
为什么对有的带框架的窗口有效,也就是说能读出其Frames窗代码,
而对一些特定的窗口,在运行到:
if (HtmlWin.name=form1.sfn.Text) or (form1.sfn.Text='ALL') then
一句时,程序就说HtmlWin.name拒绝访问,而在调试时HtmlWin.name的值却
能跟踪到,系统却不让读取其值?有没有什么好办法???
var
ShellWindow: IShellWindows;
nCount: integer;
spDisp: IDispatch;
i,j: integer;
vi,VJ,vm: OleVariant;
IE1: IWebBrowser2;
IDoc1: IHTMLDocument2;
HtmlFrame : IHTMLFramesCollection2;
HtmlWin : IHTMLWindow2;
sh:string;
begin
ShellWindow := CoShellWindows.Create;
nCount := ShellWindow.Count;
for i := 0 to nCount - 1 do
begin
vi := i;
spDisp := ShellWindow.Item(vi);
if spDisp = nil then continue;
spDisp.QueryInterface( iWebBrowser2, IE1 );
if IE1 <> nil then
begin
IE1.Document.QueryInterface(IHTMLDocument2,iDoc1);
if iDoc1 <> nil then
begin
HtmlFrame := idoc1.Get_frames;
for j:=0 to HtmlFrame.length-1 do
begin
Application.ProcessMessages;
vj:=j;
spDisp := HtmlFrame.item(vj);
if SUCCEEDED(spDisp.QueryInterface(IHTMLWindow2 ,HtmlWin))then
begin
begin
if (HtmlWin.name=form1.sfn.Text) or (form1.sfn.Text='ALL') then
begin
vm:=1;
if SUCCEEDED(HtmlWin.document.QueryInterface(IHTMLDocument2 ,IDoc1))then
begin
vj:=IDoc1.Get_all.item(0,0);
if cb.Checked then
begin
Memo2.Lines.Add('窗:'+HtmlWin.name);
Memo2.Lines.Add(vj.innerhtml); //这里是frame的网页代码啦
end;
sh:=vj.innerhtml;
Form1.hitsg(sh);
end;
end;
end;
end;
end;
Exit; //我只对第一个ie窗口使用,所以就退出
end;
end;
end;
end;
为什么对有的带框架的窗口有效,也就是说能读出其Frames窗代码,
而对一些特定的窗口,在运行到:
if (HtmlWin.name=form1.sfn.Text) or (form1.sfn.Text='ALL') then
一句时,程序就说HtmlWin.name拒绝访问,而在调试时HtmlWin.name的值却
能跟踪到,系统却不让读取其值?有没有什么好办法???