在项目中遇到了一个问题,用directdraw做的播放器在系统长时间运行后,由于系统设定了省电模式等电源选项的问题,长时间运行后播放器会出现黑屏现象。 解决方案:摘自MSDN SetThreadExecutionStateThe 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
Return ValuesIf the function succeeds, the return value is the previous thread execution state. If the function fails, the return value is NULL. RemarksActivities 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) |