Solved

Reading the ie addressline content from a second program

Posted on 2004-03-26
8
189 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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
LVL 26

Expert Comment

by:EddieShipman
ID: 10690944
Oh,

uses ..., DDEMan;
0
 
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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

776 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