Contents

LSOpenFSRef(_:_:)

Opens an item with a file-system reference in the default manner in its preferred app.

Declaration

func LSOpenFSRef(_ inRef: UnsafePointer<FSRef>!, _ outLaunchedRef: UnsafeMutablePointer<FSRef>!) -> OSStatus

Parameters

  • inRef:

    A pointer to a file-system reference designating the item to open; see the File Manager Reference in the Carbon File Management Documentation for a description of the FSRef data type.

  • outLaunchedRef:

    A pointer to a file-system reference that, on return, will identify the application launched. Pass NULL if this information is unimportant.

Return Value

A result code; see Result Codes.

Discussion

The designated item is opened in the default manner, as if it had been opened with the LSOpenFromRefSpec function with a launch specification specifying the launch flag kLSLaunchDefaults: that is, asynchronously, starting the Classic emulation environment if necessary, and with the remaining launch parameters taken from the application’s information property list. For greater control, call LSOpenFromRefSpec directly. See LSLaunchFlags for more information about launch flags.

The application is launched or activated, as required, and sent an appropriate Apple event depending on the circumstances:

  • If the item is a document, its preferred application is launched (or activated if it is already running) and sent an 'odoc' (“open document”) Apple event.

  • If the item is an application that is not already running, it is launched and sent an 'oapp' (“open application”) Apple event.

  • If the item is an application that is already running, it is activated and sent an 'rapp' (“reopen application”) Apple event.

As of macOS 10.4 and later, LSOpenItemsWithRole(_:_:_:_:_:_:_:) is the preferred way of opening an item.

Version-Notes

Thread-safe since Mac OS version 10.2.

See Also

Deprecated Functions