Function

LSOpenApplication(_:_:)

Launches the specified application.

Declaration

func LSOpenApplication(_ appParams: UnsafePointer<LSApplicationParameters>!, _ outPSN: UnsafeMutablePointer<ProcessSerialNumber>!) -> OSStatus

Parameters

inAppParams

A LSApplicationParameters structure specifying the application to launch and its launch parameters. This parameter cannot be NULL.

outPSN

On input, a pointer to a value of type ProcessSerialNumber that, on return, contains the process serial number (PSN) of the application specified by inAppParams, or NULL if you don’t want to receive the PSN.

Return Value

A result code; see Result Codes.

Discussion

The LSOpenApplication launches one application. This function is an updated alternative to the Process Manager's LaunchApplication function. Launch arguments are specified in the inAppParams argument, which must be supplied. If the application is already running in the current session, it is made the front process (unless the kLSLaunchNewInstance flag is used, which always causes a new process to be created).

If outPSN is not NULL, on return, the structure it points to contains the PSN of the launched (or activated) process. Note that for asynchronous launches, the application may not have finished launching when this function returns.

Version-Notes

Thread-safe since OS X v10.4.

See Also

Opening Items

func LSOpenFSRef(UnsafePointer<FSRef>!, UnsafeMutablePointer<FSRef>!) -> OSStatus

Opens an item designated by file-system reference, in the default manner in its preferred application.

Deprecated
func LSOpenFromRefSpec(UnsafePointer<LSLaunchFSRefSpec>!, UnsafeMutablePointer<FSRef>!) -> OSStatus

Opens one or more items designated by file-system reference, in either their preferred applications or a designated application.

Deprecated
func LSOpenCFURLRef(CFURL, UnsafeMutablePointer<Unmanaged<CFURL>?>?) -> OSStatus

Opens an item designated by URL, in the default manner in its preferred application.

func LSOpenFromURLSpec(UnsafePointer<LSLaunchURLSpec>, UnsafeMutablePointer<Unmanaged<CFURL>?>?) -> OSStatus

Opens one or more items designated by URL, in either their preferred applications or a designated application.