11 Vote

Lazarus: Open Website independent from Platform

Question by Guest | Last update on 2024-01-23 | Created on 2013-03-22

Currently, I am writing an application using Lazarus that should run on Windows, Mac and Linux. Now, I would like to set a link to my website within the program. Of course, this link should also be platform independent and should work on all of these operating systems.

As a former Delphi user, I have done this using ShellExecute and the Open command. Unfortunately, of course, this is a Windows specific function that cannot be used on a Mac or on Linux. Does anyone know a way how to set up and open a link with Lazarus?

ReplyPositiveNegative
2Best Answer2 Votes

Compared to Delphi, with Lazarus it is much easier to set a retrievable link to a website.

Simply use the function OpenUrl, for which you only have to include the unit LCLIntf:

uses
  ..., LCLIntf;

procedure ...
begin
  OpenUrl('https://www.askingbox.com');
end;

OpenUrl finds the default browser on each system and opens the specified URL with that browser. Important: Don't forget the "http" or "https" at the beginning of the URL.

You can also use OpenURL to open files, for example: OpenUrl('file://C:\file.txt'). But in that case, you can also just use OpenDocument() and pass a path to a file.
Last update on 2024-01-23 | Created on 2013-03-24

ReplyPositive Negative
Reply

Related Topics

Important Note

Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.

Participate

Ask your own question or write your own article on askingbox.com. That’s how it’s done.