Uses
MSDocW_TLB, MSHTML_TLB;
procedure TForm1.Button1Click(Sender: TObject);
var
ShellWindow: IShellWindows;
nCount: integer;
spDisp: IDispatch;
i: integer;
vi: OleVariant;
IE1: IWebBrowser2;
IDoc1: IHTMLDocument2;
begin
ShellWindow := CoShellWindows.Create;
nCount := ShellWindow.Count;
for i := 0 to nCount - 1 do
begin
vi := i;
spDisp := ShellWindow.Item(vi);
spDisp.QueryInterface( iWebBrowser2, IE1 );
//或者用: IE1 := spDisp as IWebBrowser2;
if IE1 <> nil then
begin
memo1.Lines.Add( 'Location: '+ie1.LocationName );
IDoc1 := IE1.Document as IHTMLDocument2;
if iDoc1 <> nil then
begin
memo1.Lines.add( 'Title: ' + IDOC1.Title );
memo1.Lines.add( 'Url: ' + IDOC1.url);
end;
end;
end;
end;