首页  编辑  

IShellWindow

Tags: /超级猛料/OS.操作系统/Shell.扩展/   Date Created:

uses shdocvw;

procedure TForm1.Button1Click(Sender: TObject);

var

xwin:IShellWindows;

xweb:iWebbrowser;

i:integer;

begin

xWin:=CoShellWindows.Create;

 for i:=0 to xWin.Count-1 do begin

   xWeb:=xWin.Item(i) as IWebbrowser;

   ListBox1.Items.Add(xWeb.LocationURL);

 end;

end;

********************************

var

 ShellWindow: IShellWindows;

 nCount: integer;

 spDisp: IDispatch;

 i,j: 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);

   if spDisp = nil then continue;

   spDisp.QueryInterface( iWebBrowser2, IE1 );

   if IE1 <> nil then

   begin

     IE1.Document.QueryInterface(IHTMLDocument2,iDoc1);

     if iDoc1 <> nil then

       ie1.Quit

   end;

 end;

end;

或者    if IE1 <> nil then ie1.quit ,但者可能会把资源管理器的窗口也关了