[Lazarus] FindDefaultBrowser & opening URL
Mattias Gaertner
nc-gaertnma at netcologne.de
Wed Oct 12 14:13:27 CEST 2011
On Wed, 12 Oct 2011 13:55:08 +0200
Reinier Olislagers <reinierolislagers at gmail.com> 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
More information about the Lazarus
mailing list