Chinaunix首页 | 论坛 | 博客
  • 博客访问: 71730
  • 博文数量: 21
  • 博客积分: 1478
  • 博客等级: 上尉
  • 技术积分: 220
  • 用 户 组: 普通用户
  • 注册时间: 2007-08-22 20:41
文章分类

全部博文(21)

文章存档

2011年(1)

2010年(2)

2009年(18)

我的朋友

分类:

2010-03-22 18:15:48

AuthorizationRef auth = NULL;
OSStatus err;
err = AuthorizationCreate(NULL,
            NULL,
            kAuthorizationFlagExtendRights|kAuthorizationFlagInteractionAllowed,
            &auth);
if( err != errAuthorizationSuccess ) {
    fprintf(stderr, "oops: %ld\n", (long int)err);
    exit(-1);
}
char *opts[] = { "some", "parameters", "to", "pm", NULL };
err = AuthorizationExecuteWithPrivileges(
    auth,
    "/usr/bin/pmset",
    kAuthorizationFlagDefaults,
    opts,
    NULL);
AuthorizationFree(auth, kAuthorizationFlagDefaults);
if( err != errAuthorizationSuccess ) {
    fprintf(stderr, "oops: %ld\n", (long int)err);
    exit(-1);
}


阅读(550) | 评论(0) | 转发(0) |
0

上一篇:emacs on win32

下一篇:Logviewer-mode of Emacs

给主人留下些什么吧!~~