OpenDocument function
Opens the document using the default application associated with the specified file.
Declaration
function OpenDocument(APath: string): BooleanDescription
OpenDocument is a
Boolean function used to open the
document specified in
APath using the default application for the
platform. APath can contain a fully-qualified file name or a path on the local
system. The implementation of OpenDocument is platform-specific.
For the Windows platform, the OpenURL function is called to open the specified document or path. The protocol handler for the path determines which application is used to open and display the file or path.
For the macOS platform, OpenURL is used to launch the application needed when path is a file or a directory on the local file system. Otherwise, the 'open' command is used to open the quoted value in APath.
For other UNIX-like platforms (including Linux), OpenDocument checks for well-known file managers which can be used to open and display the local resource in APath. FindFilenameOfCmd is called to choose between applications including:
- 'xdg-open'
- 'gnome-open'
- 'kfmclient'
No actions are performed in the routine if an application is not found, or the file or directory does not exist on the local file system. Otherwise, RunCmdFromPath is used to launch the file manager using the quoted value in APath as an argument.
The return value contains True if an application is available to for the specified file or path name. The return value is False if an application was not found for the specified file, or the file or path does not exist.
For the Android platform, the routine assigned to the OpenDocumentWidgetsetImplementation variable is called to display the resource.
See also
An experiment, built from Lazarus main 2dfa93c66e of 10-22-2026. Not the official Lazarus documentation.
