Difference between revisions of "OpenDocument"

From Lazarus wiki
Jump to navigationJump to search
m (→‎Definition: Fix wiki markup)
(→‎Description: Expanded description)
Line 12: Line 12:
  
 
==Description==
 
==Description==
'''opendocument''' opens a document/file with the default viewer/editor registered with the operating system for that file/file extension. E.g. on Windows, the code will use the registry to look up the file association for the extension.
+
 
 +
<syntaxhighlight lang=pascal inline>OpenDocument</syntaxhighlight> opens a document/file with the default viewer/editor registered with the operating system for that file/file extension.  
 +
 
 +
* On Windows, the code will use the registry to look up the file association for the extension.
 +
* On macOS, the code calls the [[macOS Open Sesame|open]] command line utility for files '''and''' directories. This will open the default application for the file or directory as determined by LaunchServices.
 +
 
 +
On both Windows and macOS, <syntaxhighlight lang=pascal inline>OpenDocument</syntaxhighlight> will also open a URL using the default web browser.
  
 
==Example==
 
==Example==

Revision as of 13:15, 29 March 2021

English (en) 中文(中国大陆)‎ (zh_CN)

Definition

Unit: Lazarus lclintf

function OpenDocument(APath: String): Boolean;

Official documentation: OpenDocument

Description

OpenDocument opens a document/file with the default viewer/editor registered with the operating system for that file/file extension.

  • On Windows, the code will use the registry to look up the file association for the extension.
  • On macOS, the code calls the open command line utility for files and directories. This will open the default application for the file or directory as determined by LaunchServices.

On both Windows and macOS, OpenDocument will also open a URL using the default web browser.

Example

uses 
...
lclintf
...
OpenDocument('readme.pdf');

See also