Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Netzwerke (https://www.delphipraxis.net/14-netzwerke/)
-   -   Delphi Alle IE Instanzen schließen... (https://www.delphipraxis.net/20502-alle-ie-instanzen-schliessen.html)

Evian 19. Apr 2004 10:46


Alle IE Instanzen schließen...
 
Hat jemand eine Idee, wie ich das am besten machen könnte?!

Also am liebsten, wäre es mir so:

Code:
procedure TForm1.Button1Click(Sender: TObject);
var
 ShellWindow: IShellWindows;
 WB: IWebbrowser2;
 spDisp: IDispatch;
 IDoc1: IHTMLDocument2;
 k: Integer;
begin
 ShellWindow := CoShellWindows.Create;
 for k := 0 to ShellWindow.Count do
 begin
   spDisp := ShellWindow.Item(k);
   if spDisp = nil then Continue;
   spDisp.QueryInterface(iWebBrowser2, WB);
   if WB <> nil then
   begin
     WB.Document.QueryInterface(IHTMLDocument2, iDoc1);
     if iDoc1 <> nil then
     begin
       WB := ShellWindow.Item(k) as IWebbrowser2;
       
       // ... Hier müsste sowas wie WB.close; oder so rein
     
    end;
   end;
 end;
end;
Aber mir fehlt an der einen Stelle noch der richtige Befehl!

MFG


Evian

shmia 19. Apr 2004 12:20

Re: Alle IE Instanzen schließen...
 
Versuch mal: (WB.ParentWindow AS IHTMLWindow2).Close;

Evian 19. Apr 2004 12:57

Re: Alle IE Instanzen schließen...
 
Zitat:

Zitat von shmia
Versuch mal: (WB.ParentWindow AS IHTMLWindow2).Close;

mh.. ne so geht es leider nicht ...

ich machs jetzt ein wenig umständlich über eine weitere Funktion:

Code:
procedure Tform1.KillProcess(hWindowHandle: HWND);
var
  hprocessID: INTEGER;
  processHandle: THandle;
  DWResult: DWORD;
begin
  SendMessageTimeout(hWindowHandle, WM_CLOSE, 0, 0,
    SMTO_ABORTIFHUNG or SMTO_NORMAL, 5000, DWResult);
  if isWindow(hWindowHandle) then
  begin
    GetWindowThreadProcessID(hWindowHandle, @hprocessID);
    if hprocessID <> 0 then
    begin
      processHandle := OpenProcess(PROCESS_TERMINATE or PROCESS_QUERY_INFORMATION,
        False, hprocessID);
      if processHandle <> 0 then
      begin
        TerminateProcess(processHandle, 0);
        CloseHandle(ProcessHandle);
      end;
    end;
  end;
end;

sakura 19. Apr 2004 13:15

Re: Alle IE Instanzen schließen...
 
Die Suche ist Gold wert [dp]fenster schließen[/dp] -> das 6. Ergebnis sollte es sein ;)

...:cat:...


Alle Zeitangaben in WEZ +1. Es ist jetzt 10:40 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz