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. Prevent System from sleep mode

Prevent System from sleep mode

Scheduled Pinned Locked Moved C / C++ / MFC
c++visual-studiocomtutorialquestion
6 Posts 2 Posters 1 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
    Sachin k Rajput
    wrote on last edited by
    #1

    I want to prevent or wake up my system from sleep mode programmatically using C++. I'm using SetThreadExecution() but its not working().http://msdn.microsoft.com/en-us/library/windows/desktop/aa373208%28v=vs.85%29.aspx[^] Do anyone having any idea how to do it?

    J 1 Reply Last reply
    0
    • S Sachin k Rajput

      I want to prevent or wake up my system from sleep mode programmatically using C++. I'm using SetThreadExecution() but its not working().http://msdn.microsoft.com/en-us/library/windows/desktop/aa373208%28v=vs.85%29.aspx[^] Do anyone having any idea how to do it?

      J Offline
      J Offline
      Jochen Arndt
      wrote on last edited by
      #2

      Calling

      SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED);

      should prevent the system from entering the sleep mode. Waking a system up requires that the user initiates a wake-up event like pressing the power button, a keyboard key, or moving the mouse.

      S 1 Reply Last reply
      0
      • J Jochen Arndt

        Calling

        SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED);

        should prevent the system from entering the sleep mode. Waking a system up requires that the user initiates a wake-up event like pressing the power button, a keyboard key, or moving the mouse.

        S Offline
        S Offline
        Sachin k Rajput
        wrote on last edited by
        #3

        Jochen Arndt wrote:

        Calling

        SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED);

        should prevent the system from entering the sleep mode.

        Its not working in my code..Is there any other method or trick to call it?

        Jochen Arndt wrote:

        Waking a system up requires that the user initiates a wake-up event like pressing the power button, a keyboard key, or moving the mouse.

        I want to do it programmatically. Will you suggest something?

        J 1 Reply Last reply
        0
        • S Sachin k Rajput

          Jochen Arndt wrote:

          Calling

          SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED);

          should prevent the system from entering the sleep mode.

          Its not working in my code..Is there any other method or trick to call it?

          Jochen Arndt wrote:

          Waking a system up requires that the user initiates a wake-up event like pressing the power button, a keyboard key, or moving the mouse.

          I want to do it programmatically. Will you suggest something?

          J Offline
          J Offline
          Jochen Arndt
          wrote on last edited by
          #4

          Indian Coder1989 wrote:

          Its not working in my code..Is there any other method or trick to call it?

          This is the only way I know. It may help to repeat the call in regular intervals (e.g every 5 minutes).

          Indian Coder1989 wrote:

          I want to do it programmatically. Will you suggest something?

          There is nothing to suggest because the CPU is usually not powered or in halt state when the system is in sleep mode. There must be an external event to wake-up.

          S 1 Reply Last reply
          0
          • J Jochen Arndt

            Indian Coder1989 wrote:

            Its not working in my code..Is there any other method or trick to call it?

            This is the only way I know. It may help to repeat the call in regular intervals (e.g every 5 minutes).

            Indian Coder1989 wrote:

            I want to do it programmatically. Will you suggest something?

            There is nothing to suggest because the CPU is usually not powered or in halt state when the system is in sleep mode. There must be an external event to wake-up.

            S Offline
            S Offline
            Sachin k Rajput
            wrote on last edited by
            #5

            Jochen Arndt wrote:

            This is the only way I know. It may help to repeat the call in regular intervals (e.g every 5 minutes).

            I made it using a timer and its working now. Can I do it for a period of time for which my application is running? Because its only working on a period of my timer.

            J 1 Reply Last reply
            0
            • S Sachin k Rajput

              Jochen Arndt wrote:

              This is the only way I know. It may help to repeat the call in regular intervals (e.g every 5 minutes).

              I made it using a timer and its working now. Can I do it for a period of time for which my application is running? Because its only working on a period of my timer.

              J Offline
              J Offline
              Jochen Arndt
              wrote on last edited by
              #6

              I did not really understand what you mean now. Normally, the system should not go to sleep when an application has requested this until the application terminates or clears the state. But these links may be helpful: System Sleep Criteria[^] System Wake-up Events[^]

              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