我有一些代码,只有当用户没有在安全模式下启动时才能运行。有什么方法可以使用CoreFoundation或C标准API来检测到吗?
编辑:这是我的代码,感谢我接受的答案:
#include <sys/sysctl.h>
...
int safeBoot;
int mib_name[2] = { CTL_KERN, KERN_SAFEBOOT };
size_t length = sizeof(safeBoot);
if (!sysctl(mib_name, 2, &safeBoot, &length, NULL, 0)) {
if (safeBoot == 1) {
// We are in safe mode
} else {
// Normal mode. Continue…
}
} else {
// Couldn't find safe boot information
}发布于 2014-07-23 18:48:00
您可以这样使用sysctl:
sysctl -n kern.safeboot它给出了1在safe boot模式下和0模式下的正常模式。
https://stackoverflow.com/questions/24917371
复制相似问题