Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2011-10

FindDefaultBrowser & opening URL

5 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Reinier Olislagers

Hi list,

I'm trying to open an URL in the user's browser. I've edited the example from the wiki
http://wiki.lazarus.freepascal.org/Executing_External_Programs#Open_web_page_in_default_web_browser until it compiles but I suspect I'm sending the wrong Params.

A quick look through the LCLIntf code wasn't enlightening either.

How should I write this procedure?

Thanks
Reinier

uses Process, LCLIntf
...
procedure OpenWebPage(URL: string);
var
  Browser, Params: string;
begin
  Params:='http';  //What should I do here?
  FindDefaultBrowser(Browser, Params);
  with TProcess.Create(nil) do
  try
    Executable := Browser;
    Parameters.Add(Format(Params, [URL]));
    Options := [poNoConsole];
    Execute;
  finally
    Free;
  end;
end;

Reply by email

Mattias Gaertner
to Reinier Olislagers
Show quoted text 14 lines
Hi list, I'm trying to open an URL in the user's browser. I've edited the example from the wiki http://wiki.lazarus.freepascal.org/Executing_External_Programs#Open_web_page_in_default_web_browser until it compiles but I suspect I'm sending the wrong Params. A quick look through the LCLIntf code wasn't enlightening either. How should I write this procedure? Thanks Reinier
uses Process, LCLIntf
 ...
procedure OpenWebPage(URL: string);
var
  Browser, Params: string;
begin
  FindDefaultBrowser(Browser, Params);

The params are currently done for the old version of TProcess. The URL is quoted.

  with TProcess.Create(nil) do
  try
    Executable := Browser;
    Params:=Format(Params, [URL]);
    Params:=copy(Params,2,length(Params)-2);
    Parameters.Add(Params);
    Options := [poNoConsole];
    Execute;
  finally
    Free;
  end;
end;

Mattias

Reply by email

Bart
to Mattias Gaertner

Don't we have a OpenURL() function just for for that (in LCLIntf unit)?

Bart

Mattias Gaertner wrote 50 lines
On Wed, 12 Oct 2011 13:55:08 +0200 Reinier Olislagers wrote: > Hi list, > > I'm trying to open an URL in the user's browser. I've edited the example > from the wiki > http://wiki.lazarus.freepascal.org/Executing_External_Programs#Open_web_page_in_default_web_browser > until it compiles but I suspect I'm sending the wrong Params. > > A quick look through the LCLIntf code wasn't enlightening either. > > How should I write this procedure? > > Thanks > Reinier > uses Process, LCLIntf ... procedure OpenWebPage(URL: string); var Browser, Params: string; begin FindDefaultBrowser(Browser, Params); The params are currently done for the old version of TProcess. The URL is quoted. with TProcess.Create(nil) do try Executable := Browser; Params:=Format(Params, [URL]); Params:=copy(Params,2,length(Params)-2); Parameters.Add(Params); Options := [poNoConsole]; Execute; finally Free; end; end; Mattias -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email

Reinier Olislagers
to Mattias Gaertner
Mattias Gaertner wrote 10 lines
On Wed, 12 Oct 2011 17:39:30 +0200 Bart wrote: > Don't we have a OpenURL() function just for for that (in LCLIntf unit)? Yes. But it is a good idea to give valid examples in the wiki. Mattias

True.

Still, my newb-ness prevented it from working.

Thanks for the instructions though, Matthias; this call on the command line c:\windows\system32\rundll32.exe url.dll,FileProtocolHandler "http://automation.whatismyip.com/n09230945.asp"
does work.
Just gave up on getting that into the procedure, & I'm going to use OpenURL anyway; anybody: please feel free to update the wiki ;) http://wiki.lazarus.freepascal.org/Executing_External_Programs#Open_web_page_in_default_web_browser

Thanks,

Reinier

Reply by email