Solved

Reading the ie addressline content from a second program

Posted on 2004-03-26
8
187 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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
System restore point 4 79
proper way to parse text with delphi 7 89
Delphi cmd execution 6 42
Delphi - replicating a form 8 57
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

744 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

11 Experts available now in Live!

Get 1:1 Help Now