• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Wakeup/Sleep?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Wakeup/Sleep?


  • Subject: Wakeup/Sleep?
  • From: Jerry LeVan <email@hidden>
  • Date: Wed, 17 Mar 2004 13:45:01 -0500

Hi,

I am trying to figure out how to sleep/wake the machine...
Here is some code that does not work.

#import <Foundation/Foundation.h>
#import <IOKit/pwr_mgt/IOPMLib.h>

int main (int argc, const char * argv[]) {

NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
int res;

NSCalendarDate *now = [NSCalendarDate calendarDate];
NSCalendarDate *plus30Sec = [now dateByAddingYears:0 months:0
days:0 hours:0 minutes:0 seconds:30];

NSLog(@"\nnow: %@ \nlater: %@", now, plus30Sec);

res = IOPMSchedulePowerEvent ((CFDateRef)plus30Sec,NULL, CFSTR(kIOPMAutoSleep));
NSLog(@"res=%x",res);

[pool release];
return 0;
}

The program runs and returns something that looks like some kind of error code.
Am I doing something obviously wrong? ( I run the program with root privileges).

--Jerry
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


  • Follow-Ups:
    • Re: Wakeup/Sleep?
      • From: Nicko van Someren <email@hidden>
  • Prev by Date: Re: Why can I make a new document this way?!
  • Next by Date: Re: Making an NSWindow Resizable
  • Previous by thread: Validating User Interface Items
  • Next by thread: Re: Wakeup/Sleep?
  • Index(es):
    • Date
    • Thread