SetThreadExecutionState is not working when called from windows service

前端 未结 3 999
暗喜
暗喜 2021-02-13 20:15

I want prevent system from going to sleep/hibernate from a windows service. I am calling SetThreadExecutionState function to do that. But it seems to have no effec

3条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-13 20:32

    Calling SetThreadExecutionState without ES_CONTINUOUS simply resets the idle timer; to keep the display or system in the working state, the thread must call SetThreadExecutionState periodically.

    (source)

    You need to call this function every now and then. It's not a fire-and-forget.

提交回复
热议问题