事实上,这个函数在不同的 Windows 版本之间不能交叉操作(尽管它在 Windows Vista 或更高版本中工作得很好)...在 Windows XP / 2003 中,应使用 ES_USER_PRESENT | 调用此函数。 ES_CONTINUOUS(两者都应该被调用)...这将定期重置系统和显示空闲计时器...在其他 Windows 版本中,建议您使用 ES_SYSTEM_REQUIRED | ES_DISPLAY_REQUIRED | ES_DISPLAY_REQUIRED | ES_CONTINUOUS | ES_CONTINUOUS ES_AWAYMODE_REQUIRED...
In fact, this function is not cross operable between diferent Windows versions (although it works pretty well in Windows Vista or higher)... In Windows XP / 2003 this function shall be called with ES_USER_PRESENT | ES_CONTINUOUS (both should be called)... This will reset periodically both system and display idle timers... In other Windows versions, it's recommended that you use ES_SYSTEM_REQUIRED | ES_DISPLAY_REQUIRED | ES_CONTINUOUS | ES_AWAYMODE_REQUIRED...
发布评论
评论(5)
编辑 - 我在这里使用现代电源可用性请求 API(取代
SetThreadExecutionState
)更新了答案: https://stackoverflow.com/a/63632916/67824信用:P/Invoke,死点
EDIT - I have an updated answer using the modern Power Availability Request API (supersedes
SetThreadExecutionState
) here: https://stackoverflow.com/a/63632916/67824Credit: P/Invoke, deadpoint
theoldnewthing 有您的答案:使用
SetThreadExecutionState(ES_DISPLAY_REQUIRED )
。这是由视频播放器和 PowerPoint 使用的。
theoldnewthing has your answer: Use
SetThreadExecutionState(ES_DISPLAY_REQUIRED)
.This is used by video players and PowerPoint.
这对 XP 没有帮助。
事实上,这个函数在不同的 Windows 版本之间不能交叉操作(尽管它在 Windows Vista 或更高版本中工作得很好)...在 Windows XP / 2003 中,应使用 ES_USER_PRESENT | 调用此函数。 ES_CONTINUOUS(两者都应该被调用)...这将定期重置系统和显示空闲计时器...在其他 Windows 版本中,建议您使用 ES_SYSTEM_REQUIRED | ES_DISPLAY_REQUIRED | ES_DISPLAY_REQUIRED | ES_CONTINUOUS | ES_CONTINUOUS ES_AWAYMODE_REQUIRED...
This is not helpful on XP.
In fact, this function is not cross operable between diferent Windows versions (although it works pretty well in Windows Vista or higher)... In Windows XP / 2003 this function shall be called with ES_USER_PRESENT | ES_CONTINUOUS (both should be called)... This will reset periodically both system and display idle timers... In other Windows versions, it's recommended that you use ES_SYSTEM_REQUIRED | ES_DISPLAY_REQUIRED | ES_CONTINUOUS | ES_AWAYMODE_REQUIRED...
SystemParametersInfo 和 SPI_SETSCREENSAVEACTIVE 是执行此操作的正常方法。 但是,它不会禁用屏幕锁定。
SystemParametersInfo with SPI_SETSCREENSAVEACTIVE is the normal way to do this. However, it doesn't disable screen locking.
尝试将您的表单设置为最高值true,它对我有用,即使在空闲时间之后,屏幕保护程序也不会出现...
try making your form topmost value true it works for me screen-saver never came even after the idle time...