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. Switching off hibernation [modified]

Switching off hibernation [modified]

Scheduled Pinned Locked Moved C / C++ / MFC
questioncsharpc++visual-studiowindows-admin
6 Posts 3 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.
  • T Offline
    T Offline
    tibiz
    wrote on last edited by
    #1

    Hello How can I disable/enable hibernation programatically in C++ in VS.NET ? Or need to change registry values? Thank you for any help ..will really help

    modified on Saturday, January 12, 2008 3:08:48 PM

    D T B 3 Replies Last reply
    0
    • T tibiz

      Hello How can I disable/enable hibernation programatically in C++ in VS.NET ? Or need to change registry values? Thank you for any help ..will really help

      modified on Saturday, January 12, 2008 3:08:48 PM

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

      tibiz wrote:

      Or need to change registry values?

      You can use RegSetValueEx().

      "Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman

      "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

      T 1 Reply Last reply
      0
      • D David Crow

        tibiz wrote:

        Or need to change registry values?

        You can use RegSetValueEx().

        "Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman

        "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

        T Offline
        T Offline
        tibiz
        wrote on last edited by
        #3

        Thanx, I know about registry setting. I'm trying using the GLOBAL_POWER_POLICY and if it will not help, maybe the reg. settings. Can you post me the place where to find the reg. entry ?

        D 1 Reply Last reply
        0
        • T tibiz

          Thanx, I know about registry setting. I'm trying using the GLOBAL_POWER_POLICY and if it will not help, maybe the reg. settings. Can you post me the place where to find the reg. entry ?

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

          tibiz wrote:

          Can you post me the place where to find the reg. entry ?

          It will be in the following value: HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Power\Heuristics

          "Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman

          "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

          1 Reply Last reply
          0
          • T tibiz

            Hello How can I disable/enable hibernation programatically in C++ in VS.NET ? Or need to change registry values? Thank you for any help ..will really help

            modified on Saturday, January 12, 2008 3:08:48 PM

            T Offline
            T Offline
            tibiz
            wrote on last edited by
            #5

            bool SetHibState(BYTE state) { HKEY hKey; HKEY hk; if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, SUBKEY, 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS) { BYTE byteRegData[255]; DWORD dwBufLen = 255; LONG lRet; if((lRet = RegQueryValueEx(hKey, VALNAME, NULL, NULL, byteRegData, &dwBufLen)) == ERROR_SUCCESS) { RegCloseKey(hKey); byteRegData[6]=(BYTE)state; //for(int i=0;i //printf(" %x", byteRegData[i]); if(!RegCreateKey(HKEY_LOCAL_MACHINE, SUBKEY, &hk)) { RegSetValueEx(hk, VALNAME, 0, REG_BINARY, (LPBYTE)byteRegData, (DWORD)dwBufLen); RegCloseKey(hk); } else return false; } else { RegCloseKey(hKey); return false; } } return true; } .... but the problem is, the system won't give any reaction to the change, in power options is still the old setting

            1 Reply Last reply
            0
            • T tibiz

              Hello How can I disable/enable hibernation programatically in C++ in VS.NET ? Or need to change registry values? Thank you for any help ..will really help

              modified on Saturday, January 12, 2008 3:08:48 PM

              B Offline
              B Offline
              Blake Miller
              wrote on last edited by
              #6

              If you are merely trying to keep a system 'alive' consider investing these coding tips into your application, from the MDSN topic: Using Power Management, instead of disabling the hibernate policy altogether, just keep system awake while your program is running. If user does NOT run your program, then there might be no reason the system should not hibernate. If yu need to perform some task at a scheduled time, then let it hibernate, but consider setting a waitable timer. This will wake system up and your process will resume.

              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