Function

LSOpenURLsWithRole(_:_:_:_:_:_:)

Opens one or more URLs with the specified roles.

Declaration

func LSOpenURLsWithRole(_ inURLs: CFArray!, _ inRole: LSRolesMask, _ inAEParam: UnsafePointer<AEKeyDesc>!, _ inAppParams: UnsafePointer<LSApplicationParameters>!, _ outPSNs: UnsafeMutablePointer<ProcessSerialNumber>!, _ inMaxPSNCount: CFIndex) -> OSStatus

Parameters

inURLs

An array of values of type CFURLRef.

inRole

A value of type LSRolesMask specifying one or more roles. If the role doesn’t matter, use kLSRolesAll. For possible values, see LSRolesMask. This parameter is ignored if the inAppParams parameter is not NULL.

inAEParam

A value of type AEKeyDesc that is to be attached to the Apple Event(s) generated by Launch Services with the specified AEKeyword. This parameter can be NULL.

inAppParams

An LSApplicationParameters structure specifying the application to launch and its launch parameters, in which case the inRole parameter is ignored. This parameter can be NULL, in which case an application is selected that can handle each input URL in at least one of the roles specified by the inRole parameter.

outPSNs

On input, a pointer to a caller-allocated buffer or NULL if you don’t want to receive process serial number (PSN) information. If not NULL on input, on return, the buffer contains at each index the PSN that was used to open the URL at the same index of the input URL array (inURLs).

inMaxPSNCount

The maximum number of PSNs that the buffer pointed to by outPSNs can hold.

Return Value

A result code; see Result Codes.

Discussion

This function opens the URLs specified by inURLs with the roles specified by inRole.

Each launched application receives one or more 'GURL' Apple Events specifying the URLs to be opened. You can also pass file URLs, which are interpreted as file system items and opened in the manner of LSOpenItemsWithRole(_:_:_:_:_:_:_:) (that is, a handler is selected based on the item’s filesystem metadata).If inURLs contains any application URLs, this function launches them only if the kLSRolesShell bit is set in the inRoles parameter, in which case the application is its own shell.If not NULL, the outPSNs buffer is filled with the process serial numbers that were used to open each URL at the same index of the input URL array specified by the inURLs parameter. The PSN capacity of the output buffer is specified by inMaxPSNCount.

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.