daemon 头文件_macOS开发—ServiceManagement.framework

零、ServiceManagement.framework简述

用来加载或者卸载守护进程服务。在应用内读取或调用launchd字典。简单来看这个框架很小

ServiceManagement.framework

它包含:ServiceManagement.h、SMErrors.h、SMLoginItem.h。

一、ServiceManagement.h

是ServiceManagement框架主要的头文件,这个头文件提供加载或者不加载守护进程应用,并从应用中读取和操作job字典

1、常量

1.1 kSMRightBlessPrivilegedHelper

/*!

*@abstract

* The authorization rightskeyforblessingandinstalling a privileged helper

* tool.

* 用来安装高权限helper工具的授权key

/

#define kSMRightBlessPrivilegedHelper "com.apple.ServiceManagement.blesshelper"

1.2 kSMRightModifySystemDaemons

/*!

*@abstract

* The authorization rightskeyformodifyingsystemdaemons.

* 用来调整系统守护进程的授权key*

/

#define kSMRightModifySystemDaemons "com.apple.ServiceManagement.daemons.modify"

2、常量

const CFStringRef kSMDomainSystemLaunchd:展示 Mach bootstrap 特权上下文的常量,使用这个上下文需要root权限。

const CFStringRef kSMDomainUserLaunchd:展示和调用者UID关联的 Mach bootstrap 上线文。在iOS中,这个词是 kSMDomainSystemLaunchd 的同义词。

3、方法

3.1 SMJobBless

Boolean SMJobBless(CFStringRef domain, CFStringRef executableLabel, AuthorizationRef auth, CFErrorRef *outError);

domain: 只支持 kSMDomainSystemLaunchd;

executableLabel(需要特权安装的):必须是应用程序 Info.plist 中 SMPrivilegedExecutables 中某个键对应的值;

auth:包含 kSMRightBlessPrivilegedHelper 权限的参数;

outError:提交执行工具时遇到错误的输出参数,提交成功的话,返回NULL。这个参数也可以为NULL。

二、SMErrors.h

包含ServiceManagement框架返回的错误码,使用时不需要特定引入这个框架,ServiceManagement.h已经引入。

三、SMLoginItem.h

包含的头文件:

SMLoginItemSetEnabled 方法

只有一个方法:(Mac 10.6后可用,iPhone 不可用)

BooleanSMLoginItemSetEnabled(CFStringRef identifier,Boolean enabled);

允许helper 程序放在主程序包中的 Contents/Library/LoginItems 目录;

其中:参数 identifier 是这个helper 程序的 identifier。

参数 enabled 标记这个helper 程序的状态;这个值只有在当前用户登录后才有效。如果为true,helper程序会马上启动并一直运行;如果为false,就不会再运行。

结果返回为true,代表设置已经生效。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值