athlux Posted November 20, 2008 Posted November 20, 2008 Hi all,I have to disable suspend and hibernation during the execution of my program. Otherwise my program will abort during suspend/hibernation.I've tried it with powercfg.exe but unfortunately my program is running as a service and powercfg.exe did not work as expected.I've also tried the registry fixes from sam13484 (http://www.msfn.org/board/Disable-standby-tweak-t74843.html) but they also did not work.Anyone have experience with that?It is possible to disable hibernate/suspend by a script or program and reenable the previous user settings after program is finished?Thanks in advanceAthLux
cluberti Posted November 21, 2008 Posted November 21, 2008 Set the power state(s) yourself?http://msdn.microsoft.com/en-us/library/aa373163(VS.85).aspx
athlux Posted November 23, 2008 Author Posted November 23, 2008 Thanks.On my WindowsXP I've installed Microsoft Visual C++ and developed 2 little programs:- DisableSuspend.exe - which calls SetThreadExecutionState ( ES_CONTINUOUS | ES_SYSTEM_REQUIRED )- EnableSuspend.exe - which calls SetThreadExecutionState ( ES_CONTINUOUS )Both programs work in WindowsXP but have no effect within Windows Vista I am really new in windows-programming. This are my first programs ;-)Did you have a hint what is my mistake?ThanksAthLux
cluberti Posted November 24, 2008 Posted November 24, 2008 Yes, if you read the MSDN article closely, the APIs changed from XP/2003 to Vista/2008, and the new APIs were at the top of the list.
athlux Posted November 25, 2008 Author Posted November 25, 2008 I do not fully understand.In http://msdn.microsoft.com/en-us/library/aa373163(VS.85).aspx a set of functions is listet. At the bottom some functions listet which are incompatible between XP and Vista.But the function I want to use is "SetThreadExecutionState" which is not listet in this bottom table.The function is described in detail in http://msdn.microsoft.com/en-us/library/aa373208(VS.85).aspx. Because of the bottom of this page, Requirements, I would assume that it should work in W2000, XP, Vista as well as Windows Server 2000-2008.Thanks for your helpAthLux
cluberti Posted November 25, 2008 Posted November 25, 2008 You are correct, this does appear to be something Vista supports. If it's not working, I'd consider using GetLastError to see what the return value was (check for NULL, as that is the return if it fails).
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now