Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 175
  • Last Modified:

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
 
0
wildzero
Asked:
wildzero
  • 5
  • 3
  • 2
  • +1
2 Solutions
 
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 5
  • 3
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now