0

I have a callback

WndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) {}

that checks if the windows system goes to sleep/hibernation by using WM_POWERBROADCAST event. But the same is not working for windows 7.

So for Windows 7, how it can be done? Which events is to be used? What's the difference between windows xp and windows 7 in the way of handling power events.

codeling
  • 11,056
  • 4
  • 42
  • 71
  • One difference is that Windows Vista and later won't wait if you tell them to. They'll just go right on suspending, regardless of what value you return to the OS when this event fires. – John Zwinck Feb 10 '14 at 12:59
  • 1
    You'll have to define what you mean by "not working". That phrase carries next to no information. Be specific. I suspect that you are not trying to check or track, despite what you state. I suspect that you are trying to block. – David Heffernan Feb 10 '14 at 13:01
  • I am using WM_POWERBROADCAST message handling to stop pc from going to hibernate or sleep. This works in windows xp. But the same does not works on windows 7 that means it goes to hibernate or sleep. – user3292893 Feb 10 '14 at 13:48
  • Thanks John, Then is there no way to detect when windows 7 is going to sleep or hibernate and avoid doing that – user3292893 Feb 10 '14 at 13:49

1 Answers1

0

It seems like you actually want to avoid going to sleep for some reason. For that, please see the answers posted here: Prevent windows from going into sleep when my program is running?

Community
  • 1
  • 1
John Zwinck
  • 239,568
  • 38
  • 324
  • 436