试一下
uses shdocvw;
var
ShellWindow: IShellWindows;
nCount: integer;
spDisp: IDispatch;
i: integer;
vi: OleVariant;
IE1: IWebBrowser2; //IE这里是源代码:
begin
ShellWindow := CoShellWindows.Create;
nCount := ShellWindow.Count;
for i := 0 to nCount - 1 do
begin
vi := i;
try
spDisp := ShellWindow.Item(vi);
except exit end;
if (spDisp<>nil) then
begin
try
begin
spDisp.QueryInterface( iWebBrowser2, IE1 );
end
except
on EAccessViolation do begin exit end;
end;
if (IE1 <> nil) then
begin
Log.Lines.add( IE1.Get_LocationURL());
end;
end;