Delphi interacting with IE

Hello there :)

Lets say I have 4 IE windows open, how can I get a list of the urls of these windows, the html of these windows and then be able to close them. What i'd like to do is get a list of the urls in a listbox, select the url and be able to either a) close the ie window or b) view the html in a tmemo.

Extra points can be added if required.

Many thanks
Nick
 
LVL 10
wildzeroAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mokuleCommented:
0
ginsonicCommented:
"Click Button1 to have the locationurls from all running instances of Internet Explorer - including open folders and Windows Explorer - shown in a listbox."

uses
  shdocvw_tlb;

procedure TForm1.Button1Click(Sender: TObject);
var
  x: Integer;
  Sw: IShellWindows;
begin
  sw := CoShellWindows.Create;
  for x := 0 to SW.Count - 1 do
    Listbox1.Items.Add((Sw.Item(x) as IWebbrowser2).LocationUrl);
end;


Read more at:

http://www.euromind.com/iedelphi/ie5tools/ieautomate.htm
0
ginsonicCommented:
Full project. To get URLs press Button1. TO close one, select an URL from ListBox and press Button2.

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs,shdocvw_tlb, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    ListBox1: TListBox;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
  x: Integer;
  Sw: IShellWindows;
begin
  sw := CoShellWindows.Create;
  for x := 0 to SW.Count - 1 do
    Listbox1.Items.Add((Sw.Item(x) as IWebbrowser2).LocationUrl);
end;

procedure TForm1.Button2Click(Sender: TObject);
var
  x: Integer;
  Sw: IShellWindows;
begin
   sw := CoShellWindows.Create;
  for x := 0 to SW.Count - 1 do
    if (Sw.Item(x) as IWebbrowser2).LocationURL=ListBox1.Items[ListBox1.ItemIndex] then
    (Sw.Item(x) as IWebbrowser2).Quit;
end;

end.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

ginsonicCommented:
0
ginsonicCommented:
Let me to notify you that 90 points are few points for three questions !
0
JohnjcesCommented:
Others do not have (D5) shdocvw_tlb. What is this unit and where can one find it as it is not to be found packaged with D5 Enterprise.

Thanks!
0
ginsonicCommented:
THis is not from Delphi. This is an ActiveX imported unit.

Read this to read how to install shdocvw_tlb unit.

http://www.euromind.com/iedelphi/gettingstarted/started_d5.htm
0
JohnjcesCommented:
Ginsonic
0
JohnjcesCommented:
Ginsonic

Thank-you for the link and the info! If I could I'd award a lot more points to you!

0
wildzeroAuthor Commented:
Points upped
0
wildzeroAuthor Commented:
Cheers for the answers
sorry about the delay
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.