http://bbs.csdn.net/topics/60437728

http://docwiki.embarcadero.com/Libraries/XE2/en/SHDocVw.TInternetExplorer.OnWindowClosing

 

单元 

SHDocVw  Vcl.OleServer

 

发表于: 2004-11-29 23:53:24

 
var 
i: integer
IE: TInternetExplorer;
ShellWindows: TShellWindows
bgein
  ShellWindows:=TShellWindows.Create(self); 
  IE:=TInternetExplorer.Create(self);
  ShellWindows.Connect;
  for i:=0 to ShellWindows.count -1 do
  begin
    IE.ConnectKind := ckRunningInstance;   //连接到一个IE实例
    IE.ConnectTo(ShellWindows.Item(i) as IWebBrowser2); //获得页面
    if pos('www.sina.com.cn',IE.LocationURL)>0 then
      IE.navigate('www.sohu.com.cn');
    IE.disconnect;
  end;
  ShellWindows.Disconnect;
end;
运行上面这段程序时,有时候可以成功,但大部分的时候是出现一个"invalide variant operation"错误?????实在不知道为什么,哪位DX知道????