1{%MainUnit ../lclintf.pas} 2 3 4function FindDefaultBrowser(out ABrowser, AParams: String): Boolean; 5begin 6 Result := FindPredefinedBrowser(ABrowser, AParams); 7end; 8 9// Open a given URL with the default browser 10function OpenURL(AURL: String): Boolean; 11var 12 ABrowser, AParams: String; 13begin 14 // Android uses this 15 if Assigned(OpenURLWidgetsetImplementation) then 16 begin 17 Result := OpenURLWidgetsetImplementation(AURL); 18 Exit; 19 end; 20 21 Result := FindDefaultBrowser(ABrowser, AParams) and FileExistsUTF8(ABrowser) and FileIsExecutable(ABrowser); 22 if not Result then 23 Exit; 24 RunCmdFromPath(ABrowser,Format(AParams, [AURL])); 25end; 26 27// Open a document with the default application associated with it in the system 28function OpenDocument(APath: String): Boolean; 29var 30 lApp: string; 31begin 32 // Android uses this 33 if Assigned(OpenDocumentWidgetsetImplementation) then 34 begin 35 Result := OpenDocumentWidgetsetImplementation(APath); 36 Exit; 37 end; 38 39 Result := True; 40 if not FileExistsUTF8(APath) then exit(false); 41 42 lApp:=FindFilenameOfCmd('xdg-open'); // Portland OSDL/FreeDesktop standard on Linux 43 if lApp='' then 44 lApp:=FindFilenameOfCmd('kfmclient'); // KDE command 45 if lApp='' then 46 lApp:=FindFilenameOfCmd('gnome-open'); // GNOME command 47 if lApp='' then 48 Exit(False); 49 50 if (APath<>'') and (APath[1]<>'"') then 51 APath:=QuotedStr(APath); 52 RunCmdFromPath(lApp,APath); 53end; 54