procedure
TForm1.Button1Click(Sender: TObject);
var
ShellWindow: IShellWindows;
i: Integer;
spDisp: IDispatch;
IE1: IWebBrowser2;
begin
ShellWindow := CoShellWindows.Create;
for i:=0 to ShellWindow.Count - 1 do
begin
spDisp := ShellWindow.Item(i);
if spDisp <> nil then
begin
spDisp.QueryInterface(iWebBrowser2,IE1);
if IE1 <> nil then
begin
if Pos('http://',LowerCase(IE1.LocationURL)) = 1 then
begin
Memo1.Lines.Add(IE1.LocationURL); //获取网址
Memo1.Lines.Add((IE1.Document as IHtmlDocument2).body.outerHTML); //获取源码
end;
end;
end;
end;
end;
var
ShellWindow: IShellWindows;
i: Integer;
spDisp: IDispatch;
IE1: IWebBrowser2;
begin
ShellWindow := CoShellWindows.Create;
for i:=0 to ShellWindow.Count - 1 do
begin
spDisp := ShellWindow.Item(i);
if spDisp <> nil then
begin
spDisp.QueryInterface(iWebBrowser2,IE1);
if IE1 <> nil then
begin
if Pos('http://',LowerCase(IE1.LocationURL)) = 1 then
begin
Memo1.Lines.Add(IE1.LocationURL); //获取网址
Memo1.Lines.Add((IE1.Document as IHtmlDocument2).body.outerHTML); //获取源码
end;
end;
end;
end;
end;