开发者

SetThreadExecutionState error

I entered the following code in a module and call the DoNotSleep() function but it doesn't work. Anyone can help?

Enum Execution_State
    ES_SYSTEM_REQUIRED = &H1
    ES_DISPLAY_REQUIRED = &H2
    ES_USER_PRESENT = &H4
    ES_CONTINUOUS = &H80000000
End Enum

Declare Sub SetThreadExecutionState Lib "kernel32" (ByRef esFlags As Execution_State)

Public Sub DoNotSleep()
    SetThreadExecutionState(xecution_State.ES_SYSTEM_REQUIRED Or Execution_State.ES_DISP开发者_C百科LAY_REQUIRED Or Execution_State.ES_CONTINUOUS)
End Sub


try just

SetThreadExecutionState(Execution_State.ES_SYSTEM_REQUIRED)

for me on Windows Vista it didn't reset the counter when I also used Execution_State.ES_CONTINUOUS.

The above needs to be called periodically since it resets the counter.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜