阻止OSX休眠

来源:互联网 发布:crt如何ping端口 编辑:程序博客网 时间:2024/05/22 20:06

#include <CoreServices/CoreServices.h>voidMyTimerCallback(CFRunLoopTimerRef timer, void *info){    UpdateSystemActivity(OverallAct);}intmain (int argc, const char * argv[]){    CFRunLoopTimerRef timer;    CFRunLoopTimerContext context = { 0, NULL, NULL, NULL, NULL };    timer = CFRunLoopTimerCreate(NULL, CFAbsoluteTimeGetCurrent(), 30, 0, 0, MyTimerCallback, &context);    if (timer != NULL); {        CFRunLoopAddTimer(CFRunLoopGetCurrent(), timer, kCFRunLoopCommonModes);    }    /* Start the run loop to receive timer callbacks. You don't need to    call this if you already have a Carbon or Cocoa EventLoop running. */    CFRunLoopRun();    CFRunLoopTimerInvalidate(timer);    CFRelease(timer);    return (0);}


0 0
原创粉丝点击