Click here to Skip to main content
15,887,596 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Prevent Windows From Entering Hibernate Mode Pin
Alan Balkany14-Dec-11 4:28
Alan Balkany14-Dec-11 4:28 
GeneralRe: Prevent Windows From Entering Hibernate Mode Pin
Stefan_Lang14-Dec-11 5:46
Stefan_Lang14-Dec-11 5:46 
QuestionRe: Prevent Windows From Entering Hibernate Mode Pin
David Crow14-Dec-11 6:07
David Crow14-Dec-11 6:07 
SuggestionRe: Prevent Windows From Entering Hibernate Mode Pin
Albert Holguin14-Dec-11 8:47
professionalAlbert Holguin14-Dec-11 8:47 
GeneralRe: Prevent Windows From Entering Hibernate Mode Pin
David Crow14-Dec-11 8:55
David Crow14-Dec-11 8:55 
GeneralRe: Prevent Windows From Entering Hibernate Mode Pin
Albert Holguin14-Dec-11 9:21
professionalAlbert Holguin14-Dec-11 9:21 
AnswerRe: Prevent Windows From Entering Hibernate Mode Pin
Rishav Prabhakar14-Dec-11 20:14
Rishav Prabhakar14-Dec-11 20:14 
AnswerRe: Prevent Windows From Entering Hibernate Mode Pin
Randor 14-Dec-11 10:19
professional Randor 14-Dec-11 10:19 
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 usermode could be considered a hostile act...

Best Wishes,
-David Delaune
GeneralRe: Prevent Windows From Entering Hibernate Mode Pin
Rishav Prabhakar14-Dec-11 20:39
Rishav Prabhakar14-Dec-11 20:39 
GeneralRe: Prevent Windows From Entering Hibernate Mode Pin
Chris Losinger15-Dec-11 5:59
professionalChris Losinger15-Dec-11 5:59 
AnswerRe: Prevent Windows From Entering Hibernate Mode Pin
jeff616-Dec-11 23:24
jeff616-Dec-11 23:24 
Questionabout change array length Pin
desatir731613-Dec-11 21:02
desatir731613-Dec-11 21:02 
AnswerRe: about change array length Pin
Richard MacCutchan13-Dec-11 22:15
mveRichard MacCutchan13-Dec-11 22:15 
AnswerRe: about change array length Pin
CPallini14-Dec-11 1:57
mveCPallini14-Dec-11 1:57 
JokeRe: about change array length Pin
Randor 14-Dec-11 10:31
professional Randor 14-Dec-11 10:31 
GeneralRe: about change array length Pin
CPallini14-Dec-11 11:44
mveCPallini14-Dec-11 11:44 
AnswerRe: about change array length Pin
David Crow14-Dec-11 3:27
David Crow14-Dec-11 3:27 
GeneralRe: about change array length Pin
CPallini14-Dec-11 11:43
mveCPallini14-Dec-11 11:43 
AnswerRe: about change array length Pin
szpillka15-Dec-11 5:32
szpillka15-Dec-11 5:32 
QuestionA quastion in programming language desing' scope Pin
desatir731613-Dec-11 20:43
desatir731613-Dec-11 20:43 
AnswerRe: A quastion in programming language desing' scope Pin
Orjan Westin14-Dec-11 0:05
professionalOrjan Westin14-Dec-11 0:05 
GeneralRe: A quastion in programming language desing' scope Pin
David Crow14-Dec-11 3:32
David Crow14-Dec-11 3:32 
Questionwhat is the result(union & structure)? Pin
desatir731613-Dec-11 20:32
desatir731613-Dec-11 20:32 
AnswerRe: what is the result(union & structure)? Pin
Richard MacCutchan13-Dec-11 22:13
mveRichard MacCutchan13-Dec-11 22:13 
AnswerRe: what is the result(union & structure)? Pin
CPallini14-Dec-11 2:33
mveCPallini14-Dec-11 2:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.