Adding Login Items
There are two ways to add a login item: using the Service Management framework, and using a shared file list
Login items installed using the Service Management framework are not visible in System Preferences and canonly be removed by the application that installed them.
Login items installed using a shared file list are visible in System Preferences; users have direct control overthem. If you use this API, your login item can be disabled by the user, so any other application that communicateswith it it should have reasonable fallback behavior in case the login item is disabled.
Adding Login Items Using the Service Management Framework
Applications can contain a helper application as a full application bundle, stored inside the main applicationbundle in theContents/Library/LoginItemsdirectory. Set either the LSUIElementor LSBackgroundOnlykey in theInfo.plist file of the helper application’s bundle.
Use the SMLoginItemSetEnabled function (available in OS X v10.6.6 and later) to enable a helper application.It takes two arguments, aCFStringRef containing the bundle identifier of the helper application, and aBooleanspecifying the desired state. Pass true to start the helper application immediately and indicate thatit should be started every time the user logs in. Passfalse to terminate the helper application and indicatethat it should no longer be launched when the user logs in. This function returnstrue if the requested changehas taken effect; otherwise, it returnsfalse. This function can be used to manage any number of helperapplications.
If multiple applications (for example, several applications from the same company) contain a helper applicationwith the same bundle identifier, only the one with the greatest bundle version number is launched. Any of theapplications that contain a copy of the helper application can enable and disable it.
Adding Login Items Using a Shared File List
This method is available in OS X v10.5 and later. For specific details, see the appropriate functions inLaunchServices Reference .