Lazarus

Programming => Networking and Web Programming => Topic started by: madref on October 12, 2021, 12:18:03 pm

Title: Web browser ??
Post by: madref on October 12, 2021, 12:18:03 pm
How can one check which webbrowsers are installed on a system and then choose one of them?
Title: Re: Web browser ??
Post by: Mr.Madguy on October 12, 2021, 09:20:11 pm
What OS?

On Windows you need to check something like HKLM\SOFTWARE\[Wow6432Node\]Microsoft\Windows\CurrentVersion\Uninstall.

On Linux-based system you need to run it's package manager console application and check it's output.
Title: Re: Web browser ??
Post by: speter on October 13, 2021, 12:34:11 am
I think there is a way (in windows at least) to "run" the default browser....

Have a look at "RunCommand" & "OpenDocument".

Edit: I had a look at OpenDocument; and it worked without any issues.

Code: Pascal  [Select][+][-]
  1. uses lclintf; // add this to your uses clause
  2.  
  3. ...
  4.  
  5. procedure whatever;
  6. begin
  7.   OpenDocument('somefile.html');  // opens a file (located in the exe's folder) in the default browser
  8. end;

cheers
S.
Title: Re: Web browser ??
Post by: trev on October 14, 2021, 01:29:30 am
For macOS, see LSCopyApplicationURLsForURL (https://developer.apple.com/documentation/coreservices/1445148-lscopyapplicationurlsforurl?language=objc)
Title: Re: Web browser ??
Post by: dbannon on October 14, 2021, 02:10:21 am
I think what madref wants is a list of browsers rather that the default or user chosen browser. I suspect that might be hard.

On Linux, you can search for installed packages under the Section "World Wide Web", that will pick up Firefox or Google Chrome on my Ubuntu install for example. But also wget and will not pickup Konqueror. Hmm...

What if user has decided to manually install Vivaldi ?

Maybe better to search for know binary names. Don't forget many Ubuntu users are now installing Chrome directly from Google because Ubuntu decided to make it available only in a Snap from its repositories. Sigh ...

Not easy.

Davo
Title: Re: Web browser ??
Post by: trev on October 14, 2021, 08:20:09 am
I think what madref wants is a list of browsers rather that the default or user chosen browser. I suspect that might be hard

The macOS function returns the full list of browsers with the first entry being the "preferred default" or "best" as macOS calls it.
Title: Re: Web browser ??
Post by: madref on October 15, 2021, 05:55:44 pm
For macOS, see LSCopyApplicationURLsForURL (https://developer.apple.com/documentation/coreservices/1445148-lscopyapplicationurlsforurl?language=objc)


And how can I address this in Lazarus?
Title: Re: Web browser ??
Post by: trev on October 15, 2021, 11:56:44 pm
@MadRef - see fpcsrc/fpc-3.x.x/packages/univint/src/LSInfo.pas for the Launch Services Framework.

TinyPortal © 2005-2018