开发者

What is Macintosh OSX equivilent to Windows WM_POWERBROADCAST message

开发者 https://www.devze.com 2023-02-11 02:13 出处:网络
I\'m a Windows developer, but my team counterpart on the Mac side has asked me for help with an issue our Mac client has when the user wakes up his computer from hibernation.

I'm a Windows developer, but my team counterpart on the Mac side has asked me for help with an issue our Mac client has when the user wakes up his computer from hibernation.

I handle the wake up situation in our Windows client using the Windows WM_POWERBROADCAST message. This is a message that Windows sends to applications whenever there is a change in the power state of the hardware (on/off/suspend/resume).

Does O开发者_JS百科SX support a similar notification to tell running applications that the computer is suspending, resuming, or powering up or down?

TIA.


NSWorkspace has a bunch of notifications you can listen for.

Sorry, edited because the first post was completely wrong. NSWorkspace doesn't use the default notification center for notifications. This is copied mostly out of Apple's docs.

NSNotificationCenter *notCenter;

notCenter = [[NSWorkspace sharedWorkspace] notificationCenter];
[notCenter addObserver:self
              selector:@selector(didWake:)
                  name:NSWorkspaceDidWakeNotification
                object:nil];
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号