Adding Login Items (OS X)

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


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值