织梦CMS - 轻松建站从此开始!

罗索

实现视频长时间播放而显示器不会关闭或者屏保出现的简单方法

jackyhwei 发布于 2010-12-17 20:54 点击:次 
在项目中遇到了一个问题,用directdraw做的播放器在系统长时间运行后,由于系统设定了省电模式等电源选项的问题,长时间运行后播放器会出现黑屏现象。
TAG:

在项目中遇到了一个问题,用directdraw做的播放器在系统长时间运行后,由于系统设定了省电模式等电源选项的问题,长时间运行后播放器会出现黑屏现象。

解决方案:摘自MSDN

SetThreadExecutionState

The SetThreadExecutionState function enables applications to inform the system that it is in use, thereby preventing the system from entering the sleeping power state or turning off the display while the application is running.

EXECUTION_STATE SetThreadExecutionState( EXECUTION_STATE esFlags );

Parameters

esFlags
[in] Thread's execution requirements. This parameter can be one or more of the following values.
Flag Meaning
ES_CONTINUOUS
0x80000000
Informs the system that the state being set should remain in effect until the next call that uses ES_CONTINUOUS and one of the other state flags is cleared.
ES_DISPLAY_REQUIRED
0x00000002
Forces the display to be on by resetting the display idle timer.
ES_SYSTEM_REQUIRED
0x00000001
Forces the system to be in the working state by resetting the system idle timer.

Return Values

If the function succeeds, the return value is the previous thread execution state.

If the function fails, the return value is NULL.

Remarks

Activities that are automatically detected include local keyboard or mouse input, server activity, and changing window focus. Activities that are not automatically detected include disk or CPU activity and video display.

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.

To run properly on a power-managed computer, applications such as fax servers, answering machines, backup agents, and network management applications must use ES_SYSTEM_REQUIRED | ES_CONTINUOUS when they process events. Multimedia applications, such as video players and presentation applications, must use ES_DISPLAY_REQUIRED when they display video for long periods of time without user input. Applications such as word processors, spreadsheets, browsers, and games do not need to call SetThreadExecutionState .

The SetThreadExecutionState function cannot be used to prevent the user from putting the computer in standby mode. To prevent the user from putting the computer in standby mode, the application must deny the PBT_APMQUERYSUSPEND event.

This function does not stop the screen saver from executing either.

 

原文来自:http://blog.csdn.net/wfqxx/archive/2009/09/27/4601558.aspx

(wfqxx)
本站文章除注明转载外,均为本站原创或编译欢迎任何形式的转载,但请务必注明出处,尊重他人劳动,同学习共成长。转载请注明:文章转载自:罗索实验室 [http://www.rosoo.net/a/201012/10615.html]
本文出处:CSDN博客 作者:wfqxx
顶一下
(2)
100%
踩一下
(0)
0%
------分隔线----------------------------
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
表情:
用户名: 验证码:点击我更换图片
栏目列表
将本文分享到微信
织梦二维码生成器
推荐内容