Solved

Reading the ie addressline content from a second program

Posted on 2004-03-26
8
188 Views
Last Modified: 2011-09-20
Hello !
I'm working with delphi 5 and Win98/XP.
Is it possible to read the actual content of browser address-lines (netscape and ie) from a second program (my delphi app) running in the background when doing a button-click there?
If someone have a few code lines or a link for additional help for me i'll be very happy!
Thanks a lot!
Best regards,
Ingo
0
Comment
Question by:Ogni
  • 4
  • 3
8 Comments
 
LVL 11

Expert Comment

by:shaneholmes
ID: 10689945
0
 
LVL 11

Expert Comment

by:shaneholmes
ID: 10689968

The link i provided, should do it for you, but you can also check out this site:

http://www.euromind.com/iedelphi/index.htm

for other IE related issues:

Shane
0
 
LVL 26

Accepted Solution

by:
EddieShipman earned 100 total points
ID: 10690938
I tested this with IE and it works, I don't have NS installed but this should work for it as well.

// For IE:
procedure GetIEInfo(var sURL: String; var sTitle: String);
var
  DDE:TDDEClientConv;
  sInfo: String;
  slInfo: TStringList;
begin
  slInfo := TStringList.Create;
  try
    DDE:=TDDEClientConv.Create(nil);
    try
      if DDE.SetLink('IExplore','WWW_GetWindowInfo') then
        slInfo.CommaText := DDE.RequestData('0xFFFFFFFF');
    finally
      DDE.Free;
    end;
  finally
    sURL := slInfo[0];
    sTitle := slInfo[1];
    slInfo.Free;
  end;
end;

//For Netscape:
procedure GetNetscapeInfo(var sURL: String; var sTitle: String);
var
  DDE:TDDEClientConv;
  sInfo: String;
  slInfo: TStringList;
begin
  slInfo := TStringList.Create;
  try
    DDE:=TDDEClientConv.Create(nil);
    try
      if DDE.SetLink('Netscape','WWW_GetWindowInfo') then
        slInfo.CommaText := DDE.RequestData('0xFFFFFFFF');
    finally
      DDE.Free;
    end;
  finally
    sURL := slInfo[0];
    sTitle := slInfo[1];
    slInfo.Free;
  end;
end;

//Usage:
procedure TForm1.Button1Click(Sender: TObject);
var
  sURL, sTitle: String;
begin
  GetIEInfo(sURL, sTitle);
  Memo1.Lines.Clear;
  Memo1.Lines.Add(sURL);
  Memo1.Lines.Add(sTitle);
  GetNetscapeInfo(sURL, sTitle);
end;
0
 
LVL 26

Expert Comment

by:EddieShipman
ID: 10690944
Oh,

uses ..., DDEMan;
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 11

Assisted Solution

by:shaneholmes
shaneholmes earned 100 total points
ID: 10691058
This code will retrieve the address from ALL IE instances (more than one IE open)

place a button and listbox on your form


function GetUrlFromIE (Handle: THandle; List: TStringList): boolean; stdcall;
begin
    //try to get a handle to IE's toolbar container
    hWndIEChild := FindWindowEx(hWndIE, 0, 'WorkerW', nil);
    if hWndIEChild > 0 then
    begin
      //get a handle to address bar
      hWndIEChild := FindWindowEx(hWndIEChild, 0, 'ReBarWindow32', nil);
      if hWndIEChild > 0 then
      begin
        //finally, locate combo box and add its text to the list
        hWndIEChild := FindWindowEx(hWndIEChild, 0, 'ComboBoxEx32', nil);
        if hWndIEChild > 0 then
        begin
          SendMessage(hWndIEChild, WM_GETTEXT, 255, integer(@Buffer));
          //List.AddObject(Buffer,TObject(hWndIE));
          List.Add(Buffer)
        end;
      end;
    end;
  end;
  //continue enumeration
  Result :=True;
end; (*GetUrlFromIE*)


procedure TForm1.btnRefreshClick(Sender: TObject);
begin
 listbox1.Clear;
 EnumWindows(@GetUrlFromIE, LParam(listbox1.Items));
end;


Shane
0
 
LVL 11

Expert Comment

by:shaneholmes
ID: 10691076
The GetUrlFromIE function is declared in the interface section as
 
function GetUrlFromIE (Handle: THandle; List: TStringList): boolean; stdcall;
 
This function is an application-defined callback function that receives top-level window handles as a result of a call to the EnumWindows.

Again, this is all laid out in a very nice example here:
http://delphi.about.com/library/weekly/aa060303a.htm

Shane
0
 

Author Comment

by:Ogni
ID: 10698138
Hi Eddie, hi Shane,

Thanks a lot for your help!!!
I think splitting the points is fair.

Best regards,
Ingo
0
 
LVL 26

Expert Comment

by:EddieShipman
ID: 10698558
You did say from both NS and IE, right?
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now