Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. PC wakeup from hibernation using SetWaitableTimer()

PC wakeup from hibernation using SetWaitableTimer()

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
2 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Still learning how to code
    wrote on last edited by
    #1

    Having read a number of articles on waking a PC up from hibernation, I have tried to do this using the following code:- hTimer = (HANDLE)CreateWaitableTimer(NULL, TRUE, "My Waitable test Wake Up Timer"); unsigned threadId; HANDLE hThread = (HANDLE)_beginthreadex(NULL, 0, &wakeupWatchThread, &hTimer, NULL, &threadId); return TRUE; // return TRUE unless you set the focus to a control The worker thread code is:- unsigned __stdcall wakeupWatchThread(void* dummy) { LARGE_INTEGER lElapse; int i1 = 63000; int i2 = 100000; lElapse.QuadPart = - (i1*i2); // About 10.5 mins elapsed BOOL result = SetWaitableTimer(hTimer, &lElapse, 0, TimerProc, NULL, TRUE); DWORD dwError; if(result == FALSE) dwError = GetLastError(); for (int i = 0; i < 10; i++) SleepEx(INFINITE, TRUE); return 0; } and the timer completion code is :- void CALLBACK TimerProc(LPVOID lpArgToCompletionRoutine, DWORD dwTimerLowValue, DWORD dwTimerHighValue) { CTime tNow(CTime::GetCurrentTime()); CString szTime, szMsg; szTime = tNow.Format( "%A %H:%M" ); szMsg.Format("Waitable timer expired at %s",szTime); AfxMessageBox(szMsg); } My problem is that the PC doesn't wake up !! (the last parameter of SetWaitableTimer() being set to TRUE should cause the reume from hibernation). When I manual start the PC, the timer has expired. Is there something that I'm not doing ? (Tested on Win2000 Pro only, as this will be the only target system) Doug

    S 1 Reply Last reply
    0
    • S Still learning how to code

      Having read a number of articles on waking a PC up from hibernation, I have tried to do this using the following code:- hTimer = (HANDLE)CreateWaitableTimer(NULL, TRUE, "My Waitable test Wake Up Timer"); unsigned threadId; HANDLE hThread = (HANDLE)_beginthreadex(NULL, 0, &wakeupWatchThread, &hTimer, NULL, &threadId); return TRUE; // return TRUE unless you set the focus to a control The worker thread code is:- unsigned __stdcall wakeupWatchThread(void* dummy) { LARGE_INTEGER lElapse; int i1 = 63000; int i2 = 100000; lElapse.QuadPart = - (i1*i2); // About 10.5 mins elapsed BOOL result = SetWaitableTimer(hTimer, &lElapse, 0, TimerProc, NULL, TRUE); DWORD dwError; if(result == FALSE) dwError = GetLastError(); for (int i = 0; i < 10; i++) SleepEx(INFINITE, TRUE); return 0; } and the timer completion code is :- void CALLBACK TimerProc(LPVOID lpArgToCompletionRoutine, DWORD dwTimerLowValue, DWORD dwTimerHighValue) { CTime tNow(CTime::GetCurrentTime()); CString szTime, szMsg; szTime = tNow.Format( "%A %H:%M" ); szMsg.Format("Waitable timer expired at %s",szTime); AfxMessageBox(szMsg); } My problem is that the PC doesn't wake up !! (the last parameter of SetWaitableTimer() being set to TRUE should cause the reume from hibernation). When I manual start the PC, the timer has expired. Is there something that I'm not doing ? (Tested on Win2000 Pro only, as this will be the only target system) Doug

      S Offline
      S Offline
      Still learning how to code
      wrote on last edited by
      #2

      Perhaps, I should have emphasised the question in my mind - "Do I have to do anything within the OS (Win2K) to allow the wakeup to occur" ?

      Doug

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups