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