Programmatically prevent Windows screensaver from starting

后端 未结 13 2053
心在旅途
心在旅途 2020-12-03 00:58

Is there a recommended way to prevent the Windows screensaver from starting? The closest thing I\'ve found is this article, but what I would really like to do is just tell

13条回答
  •  心在旅途
    2020-12-03 01:52

    You can use SystemParametersInfo to get the SCREENSAVETIMEOUT and then immediately set the timeout back to the same value. Do this periodically on a timer for as long as you want to prevent the screensaver from going on.

    This has the effect of resetting the current countdown timer without actually changing the system setting.

    You probably also want to call SetThreadExecutionState to affect the power as other answers mention.

提交回复
热议问题