Originally Posted By: tfabris
right after DWORD delaySeconds = 30;


If you think about what that line's actually saying -- "I need the display" -- you'll see that it's probably better (though I'm not saying it'll definitely work; it's been a while since I delved into the vagaries of Windows power management) to put it right after the WaitForSingleObject(..., INFINITE) completes -- i.e. once the computer's woken up again.
_________________________
-- roger