All applications available on the user’s system must be registered to make them known to Launch Services and copy their document binding and other information into its database. It isn’t ordinarily necessary to perform this task explicitly, since a variety of utilities and services built into the Mac OS X system software take care of it automatically:
A built-in background tool, run whenever the system is booted or a new user logs in, automatically searches the Applications folders in the system, network, local, and user domains and registers any new applications it finds there. (This operation is analogous to “rebuilding the desktop” in earlier versions of Mac OS.)
The Finder automatically registers all applications as it becomes aware of them, such as when they are dragged onto the user’s disk or when the user navigates to a folder containing them.
When the user attempts to open a document for which no preferred application can be found in the Launch Services database, the Finder presents a dialog asking the user to select an application with which to open the document. It then registers that application before launching it.
In spite of these automatic registration utilities, it may sometimes be necessary to register an application explicitly with Launch Services. For example, although developers are encouraged to package their applications so that they can be installed by simply dragging them onto the user’s disk, some applications may require more elaborate custom installer software. In such cases, the installer should call one of the Launch Services registration functions LSRegisterFSRef or LSRegisterURL to register the application explicitly.
The registration functions take a Boolean parameter, inUpdate, which controls the function’s behavior when the application being registered already exists in the Launch Services database. If this parameter is true, Launch Services unconditionally reregisters the application, replacing any previous information that may already exist for it in the database; if the parameter is false, the application is reregistered only if its current modification time is more recent than that recorded in the database.
After making any significant change in an application’s Launch Services–related information, you should either reregister the application explicitly, by calling LSRegisterFSRef or LSRegisterURL with inUpdate set to true, or update the modification time of the application to ensure that it will be updated by the automatic registration utilities described above.
Note: You can update an application’s modification time using the BSD touch command in a Terminal window. For example, the command touch /Applications/TextEdit.app sets the modification time of TextEdit to the current time.
Last updated: 2007-08-23