unit my_pub_functions;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils,LazHelpHTML,UTF8Process;
var
s____:string;
resourcestring
a____='t';
// Open url use default web browser
procedure OpenUrl(url1:String);
implementation
procedure OpenUrl(url1:String);
var
v: THTMLBrowserHelpViewer;
BrowserPath, BrowserParams: string;
p: LongInt;
URL: String;
BrowserProcess: TProcessUTF8;
begin
v:=THTMLBrowserHelpViewer.Create(nil);
try
v.FindDefaultBrowser(BrowserPath,BrowserParams); //此句会找到系统的默认浏览器,然后打开网址【支持windows及linux】
URL:=url1;
p:=System.Pos('%s', BrowserParams);
System.Delete(BrowserParams,p,2);
System.Insert(URL,BrowserParams,p);
BrowserProcess:=TProcessUTF8.Create(nil);
try
BrowserProcess.CommandLine:=BrowserPath+' '+BrowserParams;
BrowserProcess.Execute;
finally
BrowserProcess.Free;
end;
finally
v.Free;
end;
end;
end. |