procedure TForm1.Button1Click(Sender: TObject);
var
ShellWindows: IShellWindows;
i: Integer;
begin
ShellWindows := CoShellWindows.Create;
for i := 0 to ShellWindows.Count - 1 do
Memo1.Lines.Append((ShellWindows.Item(i) as IWebBrowser2).LocationURL);
end;
上述代码是可以的,你自己增加一下判断URL内容就可以了
if ShellWindows.Count < 1 then // 没有打开的IE浏览器
if Pos('csdn.net', LowerCase((ShellWindows.Item(i) as IWebBrowser2).LocationURL)) > 0 then // 有IE浏览器的URL指向csdn