2008. szeptember 25., csütörtök

Detect the current URL in Internet Explorer


Problem/Question/Abstract:

Detect the current URL in Internet Explorer

Answer:

You can quickly retrieve the current Internet Explorer's URL with DDE.

There are a few problems with this technique:

multiple instances of IE could be open - you have no control to which one you connect
one instance with multiple windows could be open (created with IE's menu File | New | Window). Again, you have no control which one you connect to.

Ultimately, you could use EnumChildWindows() calls to check for any open IE window. This could would have to be customized for each new IE release..

uses
  DDEMan;

// TForm type declaration...

procedure TForm1.Button1Click(Sender: TObject);
var
  DDE: TDDEClientConv;
begin
  DDE := TDDEClientConv.Create(self);
  if DDE.SetLink('IExplore', 'WWW_GetWindowInfo') then
    Memo1.Lines.Add(DDE.RequestData('0xFFFFFFFF,sURL,sTitle'));
  DDE.Free;
end;

Nincsenek megjegyzések:

Megjegyzés küldése