Function

LSOpenItemsWithRole(_:_:_:_:_:_:_:)

Opens items specified as an array of values of type FSRef with a specified role.

Declaration

func LSOpenItemsWithRole(_ inItems: UnsafePointer<FSRef>!, _ inItemCount: CFIndex, _ inRole: LSRolesMask, _ inAEParam: UnsafePointer<AEKeyDesc>!, _ inAppParams: UnsafePointer<LSApplicationParameters>!, _ outPSNs: UnsafeMutablePointer<ProcessSerialNumber>!, _ inMaxPSNCount: CFIndex) -> OSStatus

Parameters

inItems

An array of values of type FSRef.

inItemCount

The number of items specified in inItems.

inRole

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

inAEParam

An 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 item 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 item at the same index of the input item array (inItems).

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 specified items with the specified role. You can optionally specify the application and launch parameters in the inAppParams parameter. If an application is specified in the inAppParams parameter, the inRole parameter is ignored and the application is launched (if necessary).

Each application (regardless of whether it is launched or already running) receives an 'odoc' Apple Event specifying the items that are to be opened.

If the inItems array contains any applications, this function launches them only if the kLSRolesShell bit is set in the inRoles parameter to indicate that the operating system should use the application itself as the execution shell of the new process.

If not NULL, the outPSNs buffer is filled with the PSN that was used to open each item at the same index of the inItems array. 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.