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 Windows From Entering Hibernate Mode

Prevent Windows From Entering Hibernate Mode

Scheduled Pinned Locked Moved C / C++ / MFC
javaquestion
12 Posts 8 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.
  • R Rishav Prabhakar

    Hello, I have to prevent Windows 7 from entering Hibernate mode. Preventing it to enter SLEEP mode was done by "SetThreadExecutionState(ES_CONTINUOUS |ES_AWAYMODE_REQUIRED|ES_SYSTEM_REQUIRED|ES_DISPLAY_REQUIRED);" but this code doesn't stop windows from entering Hibernation. what can be done to achieve the above..??

    A Offline
    A Offline
    Alan Balkany
    wrote on last edited by
    #2

    This is guaranteed to prevent your computer from entering hibernate mode: http://4.bp.blogspot.com/_u1F1h_LaJsc/SaOX7AT2v6I/AAAAAAAAA1M/AK5gzNvVqq8/s400/smash+computer.jpg[^]

    S 1 Reply Last reply
    0
    • A Alan Balkany

      This is guaranteed to prevent your computer from entering hibernate mode: http://4.bp.blogspot.com/_u1F1h_LaJsc/SaOX7AT2v6I/AAAAAAAAA1M/AK5gzNvVqq8/s400/smash+computer.jpg[^]

      S Offline
      S Offline
      Stefan_Lang
      wrote on last edited by
      #3

      Actually this looks more like preventing the computer from ever leaving it again! :laugh:

      1 Reply Last reply
      0
      • R Rishav Prabhakar

        Hello, I have to prevent Windows 7 from entering Hibernate mode. Preventing it to enter SLEEP mode was done by "SetThreadExecutionState(ES_CONTINUOUS |ES_AWAYMODE_REQUIRED|ES_SYSTEM_REQUIRED|ES_DISPLAY_REQUIRED);" but this code doesn't stop windows from entering Hibernation. what can be done to achieve the above..??

        D Offline
        D Offline
        David Crow
        wrote on last edited by
        #4

        I'm sure you have a good reason, but if a user has configured the computer TO use hibernation, why would you want to circumvent that?

        "One man's wage rise is another man's price increase." - Harold Wilson

        "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

        "Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous

        A R 2 Replies Last reply
        0
        • D David Crow

          I'm sure you have a good reason, but if a user has configured the computer TO use hibernation, why would you want to circumvent that?

          "One man's wage rise is another man's price increase." - Harold Wilson

          "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

          "Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous

          A Offline
          A Offline
          Albert Holguin
          wrote on last edited by
          #5

          Kiosk software would be one such example.

          D 1 Reply Last reply
          0
          • A Albert Holguin

            Kiosk software would be one such example.

            D Offline
            D Offline
            David Crow
            wrote on last edited by
            #6

            Yes, you would most definitely not want a kiosk to hibernate. But I don't see how that relates to the OP's request. I understood it to mean he wanted to keep a machine, that is configured TO hibernate, FROM hibernating. A kiosk does not fit that description. :confused:

            "One man's wage rise is another man's price increase." - Harold Wilson

            "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

            "Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous

            A 1 Reply Last reply
            0
            • D David Crow

              Yes, you would most definitely not want a kiosk to hibernate. But I don't see how that relates to the OP's request. I understood it to mean he wanted to keep a machine, that is configured TO hibernate, FROM hibernating. A kiosk does not fit that description. :confused:

              "One man's wage rise is another man's price increase." - Harold Wilson

              "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

              "Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous

              A Offline
              A Offline
              Albert Holguin
              wrote on last edited by
              #7

              Well, it would certainly make deployment easier... Just load the kiosk software, when running, it makes sure the computer settings don't interrupt it, when not running...works as a regular computer.

              1 Reply Last reply
              0
              • R Rishav Prabhakar

                Hello, I have to prevent Windows 7 from entering Hibernate mode. Preventing it to enter SLEEP mode was done by "SetThreadExecutionState(ES_CONTINUOUS |ES_AWAYMODE_REQUIRED|ES_SYSTEM_REQUIRED|ES_DISPLAY_REQUIRED);" but this code doesn't stop windows from entering Hibernation. what can be done to achieve the above..??

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #8

                Hi, Are you making a single call to the SetThreadExecutionState function[^]? The NT kernel tracks how long the user has been idle... by keeping track of the last time the mouse/keyboard has been used or last time it recieved any type of HID input. When you make that call to SetThreadExecutionState[^]... all it does it set the idle time back to zero. You need to call it over and over again to continuously reset the user idle-count. I recommend the following: 1.) Make your call to SetThreadExecutionState[^]. 2.) Then use the the CallNtPowerInformation function[^] with the SystemPowerInformation index and populate a SYSTEM_POWER_INFORMATION structure[^]. 3.) Read the unsigned long SYSTEM_POWER_INFORMATION.TimeRemaining which represents seconds remaining before the user is considered idle and save it. 4.) Begin a window,thread or multimedia timer with a period less than the TimeRemaining you obtained in the previous step. 5.) When your timer fires... call the SetThreadExecutionState function[^] again. Laptop manufacturers have been known to write device drivers that interfere with preventing hibernation from usermode so your mileage may vary. Preventing hibernation from usermo

                R 1 Reply Last reply
                0
                • D David Crow

                  I'm sure you have a good reason, but if a user has configured the computer TO use hibernation, why would you want to circumvent that?

                  "One man's wage rise is another man's price increase." - Harold Wilson

                  "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

                  "Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous

                  R Offline
                  R Offline
                  Rishav Prabhakar
                  wrote on last edited by
                  #9

                  the problem arises that the device i m working with stops responding.. so as my client requires this functionality to continue altogether when the system resumes from hibernate.. or he asked that the system should not go into hibernate.. since there is nothing we can do with the device hence stopping the windows from entering hibernate was the best option..

                  1 Reply Last reply
                  0
                  • L Lost User

                    Hi, Are you making a single call to the SetThreadExecutionState function[^]? The NT kernel tracks how long the user has been idle... by keeping track of the last time the mouse/keyboard has been used or last time it recieved any type of HID input. When you make that call to SetThreadExecutionState[^]... all it does it set the idle time back to zero. You need to call it over and over again to continuously reset the user idle-count. I recommend the following: 1.) Make your call to SetThreadExecutionState[^]. 2.) Then use the the CallNtPowerInformation function[^] with the SystemPowerInformation index and populate a SYSTEM_POWER_INFORMATION structure[^]. 3.) Read the unsigned long SYSTEM_POWER_INFORMATION.TimeRemaining which represents seconds remaining before the user is considered idle and save it. 4.) Begin a window,thread or multimedia timer with a period less than the TimeRemaining you obtained in the previous step. 5.) When your timer fires... call the SetThreadExecutionState function[^] again. Laptop manufacturers have been known to write device drivers that interfere with preventing hibernation from usermode so your mileage may vary. Preventing hibernation from usermo

                    R Offline
                    R Offline
                    Rishav Prabhakar
                    wrote on last edited by
                    #10

                    That's the client side requirement so this wont be a hostile act.. and this code wont allow window to any state.. system will be continuously ON in windows 7

                    C 1 Reply Last reply
                    0
                    • R Rishav Prabhakar

                      That's the client side requirement so this wont be a hostile act.. and this code wont allow window to any state.. system will be continuously ON in windows 7

                      C Offline
                      C Offline
                      Chris Losinger
                      wrote on last edited by
                      #11

                      can't you just disable hibernation from the OS's power settings ? seems cleaner than trying to do it from an application.

                      image processing toolkits | batch image processing

                      1 Reply Last reply
                      0
                      • R Rishav Prabhakar

                        Hello, I have to prevent Windows 7 from entering Hibernate mode. Preventing it to enter SLEEP mode was done by "SetThreadExecutionState(ES_CONTINUOUS |ES_AWAYMODE_REQUIRED|ES_SYSTEM_REQUIRED|ES_DISPLAY_REQUIRED);" but this code doesn't stop windows from entering Hibernation. what can be done to achieve the above..??

                        J Offline
                        J Offline
                        jeff6
                        wrote on last edited by
                        #12

                        Juts disable it by schemes code had been posted many times on pro win32 group

                        news://nntp.aioe.org/comp.os.ms-windows.programmer.win32
                        or http://tinyurl.com/cmhb5g by Google

                        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