Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
Get the HTML Code out of all Internet Explorer Instances Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
02-Oct-04
Category
COM+
Language
Delphi 5.x
Views
200
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Attila Torda-Pilisi

Get the HTML Code out of all Internet Explorer Instances?

Answer:

1   uses
2     MSHTML_TLB, ActiveX;
3   
4   function GetHTMLCode(WB: IWebbrowser2; ACode: TStrings): Boolean;
5   var
6     ps: IPersistStreamInit;
7     s: string;
8     ss: TStringStream;
9     sa: IStream;
10  begin
11    ps := WB.document as IPersistStreamInit;
12    s := '';
13    ss := TStringStream.Create(s);
14    try
15      sa := TStreamAdapter.Create(ss, soReference) as IStream;
16      Result := Succeeded(ps.Save(sa, Bool(True)));
17      if Result then
18        ACode.Add(ss.Datastring);
19    finally
20      ss.Free;
21    end;
22  end;
23  
24  procedure TForm1.Button1Click(Sender: TObject);
25  var
26    ShellWindow: IShellWindows;
27    WB: IWebbrowser2;
28    spDisp: IDispatch;
29    IDoc1: IHTMLDocument2;
30    k: Integer;
31  begin
32    ShellWindow := CoShellWindows.Create;
33    // get the running instance of Internet Explorer
34    for k := 0 to ShellWindow.Count do
35    begin
36      spDisp := ShellWindow.Item(k);
37      if spDisp = nil then
38        Continue;
39      // QueryInterface determines if an interface can be used with an object
40      spDisp.QueryInterface(iWebBrowser2, WB);
41      if WB <> nil then
42      begin
43        WB.Document.QueryInterface(IHTMLDocument2, iDoc1);
44        if iDoc1 <> nil then
45        begin
46          WB := ShellWindow.Item(k) as IWebbrowser2;
47          begin
48            // Add HTML Code to Memo
49            Memo1.Lines.Add('****************************************');
50            Memo1.Lines.Add(WB.LocationURL);
51            Memo1.Lines.Add('****************************************');
52            GetHTMLCode(WB, Memo1.Lines);
53          end;
54        end;
55      end;
56    end;
57  end;


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC