Contents

LSGetApplicationForItem(_:_:_:_:)

Locates the preferred app for opening an item with a file-system reference.

Declaration

func LSGetApplicationForItem(_ inItemRef: UnsafePointer<FSRef>!, _ inRoleMask: LSRolesMask, _ outAppRef: UnsafeMutablePointer<FSRef>!, _ outAppURL: UnsafeMutablePointer<Unmanaged<CFURL>?>!) -> OSStatus

Parameters

  • inItemRef:

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

  • inRolesMask:

    A bit mask specifying the application’s desired role or roles with respect to the designated item; see Lsrolesmask for a description of this mask. If the role is unimportant, pass kLSRolesAll.

  • outAppRef:

    A pointer to a file-system reference that, on return, will identify the item’s preferred application; see the File Manager Reference in the Carbon File Management Documentation for a description of the FSRef data type. Pass NULL if you are not interested in identifying the preferred application in this form; however, this parameter and outAppURL cannot both be NULL.

  • outAppURL:

    A pointer to a Core Foundation URL reference that, on return, will identify the item’s preferred application; see the CFURL Reference in the Core Foundation Reference Documentation for a description of the CFURLRef data type. Pass NULL if you are not interested in identifying the preferred application in this form; however, this parameter and outAppRef cannot both be NULL.

    Despite the absence of the word Copy in its name, this function retains the URL reference object on your behalf; you are responsible for releasing this object.

Return Value

A result code; see Launch Services. If no application suitable for opening the item is found in the Launch Services database, the function will return the result code kLSApplicationNotFoundErr.

Discussion

Thread-safe since Mac OS version 10.2.

See Also

Deprecated Functions