Jump to content

disable suspend/hibernate during program execution


Recommended Posts

Posted

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 advance

AthLux


Posted

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 :unsure:

I am really new in windows-programming. This are my first programs ;-)

Did you have a hint what is my mistake?

Thanks

AthLux

Posted

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.

Posted

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 help

AthLux

Posted

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).

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...