Important screensaver tip for Windows emulator authors

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

User avatar
James
Posts: 429
Joined: Sat Jan 22, 2005 8:51 am
Location: Chicago, IL
Contact:

Re: Important screensaver tip for Windows emulator authors

Post by James » Fri Jul 01, 2016 2:18 pm

cool -- just tested the Power Management API and it seems to work well. Even with my workstation set to lock. Thanks!
get nemulator
http://nemulator.com

Nax
Posts: 2
Joined: Wed Sep 25, 2019 2:12 am

Re: Important screensaver tip for Windows emulator authors

Post by Nax » Sun Apr 19, 2020 6:49 am

Another Win32 function I didn't see mentionned on this thread is SetThreadExecutionState, which is compatible with Windows XP and newer.

You can call it periodically like this:

Code: Select all

SetThreadExecutionState(ES_DISPLAY_REQUIRED | ES_SYSTEM_REQUIRED)
to reset the sleep timer and the screen blanking/screensaver timer, or you can use the ES_CONTINUOUS flag to make the setting stick.

Code: Select all

SetThreadExecutionState(ES_CONTINUOUS | ES_DISPLAY_REQUIRED | ES_SYSTEM_REQUIRED)
will disable windows sleep and the screensaver, while

Code: Select all

SetThreadExecutionState(ES_CONTINUOUS)
will re-enable them.

Post Reply