Hallo,
ich möchte geren vom activen Internet Explorer - Fenster den Quellcode auslesen.
Habe den unteren Code gefunden:
leider bekomme ich von diesem code von allen Fenstern und Programmen die InternetExplorer benutzten den Quellcode
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50:
| function GetHTMLCode(WB: IWebbrowser2; ACode: TStrings): Boolean; var ps: IPersistStreamInit; s: string; ss: TStringStream; sa: IStream; begin ps := WB.document as IPersistStreamInit; s := ''; ss := TStringStream.Create(s); try sa := TStreamAdapter.Create(ss, soReference) as IStream; Result := Succeeded(ps.Save(sa, Bool(True))); if Result then ACode.Add(ss.Datastring); finally ss.Free; end; end;
procedure Tmm_form.FlatButton5Click(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; begin GetHTMLCode(WB, JvMemo1.Lines); end; end; end; end; end; |
Moderiert von
matze: Code- durch Delphi-Tags ersetzt