SetThreadExecutionState错误

时间:2011-04-27 05:32:31

标签: windows

我在模块中输入以下代码并调用DoNotSleep()函数,但它不起作用。有人可以帮忙吗?

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_DISPLAY_REQUIRED Or Execution_State.ES_CONTINUOUS)
End Sub

1 个答案:

答案 0 :(得分:0)

尝试

SetThreadExecutionState(Execution_State.ES_SYSTEM_REQUIRED)

对于我在Windows Vista上,当我也使用Execution_State.ES_CONTINUOUS时,它没有重置计数器。

上述需要定期调用,因为它会重置计数器。