2009. május 28., csütörtök

How to check if Netscape or IExplorer is running and get the current URL


Problem/Question/Abstract:

How can I find out if Netscape is running or not? And if it is running, how can I get the current URL address that is displaying? The same with IE.

Answer:

Here's an example which gets you both the URL and the title of the page into one string. For explorer replace 'Netscape' with 'IExplorer':


uses
  DdeMan;

procedure TForm1.Button1Click(Sender: TObject);
var
  DDE: TDdeClientConv;
begin
  DDE := TDdeClientConv.Create(self);
  if DDE.SetLink('Netscape', 'WWW_GetWindowInfo') then
    Edit1.Text := DDE.RequestData('0xFFFFFFFF, sURL, sTitle')
  else
    ShowMessage('Netscape is not running');
  DDE.Free;
end;

Nincsenek megjegyzések:

Megjegyzés küldése