网站首页  词典首页

请输入您要查询的函数:

 

术语 setthreadexecutionstate
释义 SetThreadExecutionState
语法:
C++
EXECUTION_STATE WINAPI SetThreadExecutionState(
__in EXECUTION_STATE esFlags
);
SetThreadExecutionState功能
使应用程序告知制度,它是在使用,从而防止进入休眠或关闭显示系统,同时在应用程序运行。
参数
esFlags [in]
线程的执行要求。此参数可以是一个或多个下列值。
ValueMeaning
ES_AWAYMODE_REQUIRED
0x00000040Enables离开模式。此值必须指定的ES_CONTINUOUS。
离开模式应该仅用于媒体录制和媒体分发的应用程序必须执行的关键在台式计算机后台处理,而电脑似乎是睡觉。见备注。
Windows Server 2003和Windows XP/2000操作系统:ES_AWAYMODE_REQUIRED不支持。
ES_CONTINUOUS
0x80000000Informs的,国家正在建立应继续有效,直到下一次调用,它使用ES_CONTINUOUS和其他国家的标志之一,是清除系统。
ES_DISPLAY_REQUIRED
0x00000002Forces的汇演由重置显示空闲计时器。
ES_SYSTEM_REQUIRED
0x00000001Forces该系统的工作状态被重置系统空闲计时器。
ES_USER_PRESENT
0x00000004This价值不支持。如果ES_USER_PRESENT与其他价值观esFlags相结合,调用将失败,并指定国家都将被设置。
Windows Server 2003和Windows XP/2000操作系统:通知系统,用户是当前和显示器和重置系统空闲计时器。 ES_USER_PRESENT必须调用ES_CONTINUOUS。
返回值
如果函数成功,返回值是前一个线程的执行状态。
如果函数失败,返回值为NULL。
备注
该系统会自动检测,如本地键盘或鼠标输入,服务器活动活动,改变窗口焦点。活动不包括自动检测硬盘或CPU活动和视频显示。
调用没有ES_CONTINUOUS SetThreadExecutionState简单重置空闲计时器,保持在工作状态显示或系统的线程必须调用SetThreadExecutionState定期。
如果要在适当的权力管理的计算机,如传真服务器的应用,应答机,备份代理和网络管理应用程序必须同时使用ES_SYSTEM_REQUIRED和ES_CONTINUOUS当他们处理事件。多媒体应用,如视频播放器和演示应用,必须使用ES_DISPLAY_REQUIRED显示时,很长时间没有用户输入的视频。如字处理,电子表格,浏览器应用程序,游戏并不需要调用SetThreadExecutionState。
在ES_AWAYMODE_REQUIRED值应只用于在绝对必要的媒体应用需要的制度,以执行诸如录制电视流媒体内容或其他设备的后台任务在系统似乎睡觉。应用程序不需要关键后台处理,或在便携式计算机上运行不应该启用离开模式,因为它阻止节约电力输入正确的睡眠系统。
要启用离开模式,一个应用程序同时使用ES_AWAYMODE_REQUIRED和ES_CONTINUOUS;禁用离开模式,应用程序调用ES_CONTINUOUS SetThreadExecutionState并清除ES_AWAYMODE_REQUIRED。当距离模式被激活,任何行动都将计算机置于睡眠模式,而不是远离它。计算机似乎睡着了,而该制度继续执行任务,不需要用户输入。离开模式不影响睡眠空闲计时器,以防止其进入睡眠计时器到期时,系统,应用程序还必须设置ES_SYSTEM_REQUIRED值。
该SetThreadExecutionState函数不能用于防止把计算机进入睡眠状态的用户。应用程序应该尊重用户期望某种行为结束时,他们的笔记本电脑的盖子或按电源按钮。
此函数不停止执行屏幕保护程序。
实例
/ /电视录制的开始。启用离开模式和预防
/ /睡眠空闲超时。
/ /
SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED | ES_AWAYMODE_REQUIRED);
/ /
/ /等待,直到录音完成...
/ /
/ /
/ /清除EXECUTION_STATE标志禁用离开模式,让系统空闲进行正常睡眠。
/ /
SetThreadExecutionState(ES_CONTINUOUS);
要求:
最低支持:client-Windows 2000专业版
最低支持server-Windows 2000服务器
HeaderWinbase.h(头文件:winuser.h)
LibraryKernel32.lib
DLLKernel32.dll
参见
电源管理功能
SetSuspendState
SetSystemPowerState
WM_POWERBROADCAST
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年7月30日
==英文原文==SetThreadExecutionState Function
Enables an application to inform the system that it is in use, thereby preventing the system from entering sleep or turning off the display while the application is running.
Syntax
C++
EXECUTION_STATE WINAPI SetThreadExecutionState(
__in EXECUTION_STATE esFlags
);
Parameters
esFlags [in]
The thread's execution requirements. This parameter can be one or more of the following values.
ValueMeaning
ES_AWAYMODE_REQUIRED
0x00000040Enables away mode. This value must be specified with ES_CONTINUOUS.
Away mode should be used only by media-recording and media-distribution applications that must perform critical background processing on desktop computers while the computer appears to be sleeping. See Remarks.
Windows Server 2003 and Windows XP/2000: ES_AWAYMODE_REQUIRED is not supported.
ES_CONTINUOUS
0x80000000Informs 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
0x00000002Forces the display to be on by resetting the display idle timer.
ES_SYSTEM_REQUIRED
0x00000001Forces the system to be in the working state by resetting the system idle timer.
ES_USER_PRESENT
0x00000004This value is not supported. If ES_USER_PRESENT is combined with other esFlags values, the call will fail and none of the specified states will be set.
Windows Server 2003 and Windows XP/2000: Informs the system that a user is present and resets the display and system idle timers. ES_USER_PRESENT must be called with ES_CONTINUOUS.

Return Value
If the function succeeds, the return value is the previous thread execution state.
If the function fails, the return value is NULL.
Remarks
The system automatically detects activities such as 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 both ES_SYSTEM_REQUIRED and 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 ES_AWAYMODE_REQUIRED value should be used only when absolutely necessary by media applications that require the system to perform background tasks such as recording television content or streaming media to other devices while the system appears to be sleeping. Applications that do not require critical background processing or that run on portable computers should not enable away mode because it prevents the system from conserving power by entering true sleep.
To enable away mode, an application uses both ES_AWAYMODE_REQUIRED and ES_CONTINUOUS; to disable away mode, an application calls SetThreadExecutionState with ES_CONTINUOUS and clears ES_AWAYMODE_REQUIRED. When away mode is enabled, any operation that would put the computer to sleep puts it in away mode instead. The computer appears to be sleeping while the system continues to perform tasks that do not require user input. Away mode does not affect the sleep idle timer; to prevent the system from entering sleep when the timer expires, an application must also set the ES_SYSTEM_REQUIRED value.
The SetThreadExecutionState function cannot be used to prevent the user from putting the computer to sleep. Applications should respect that the user expects a certain behavior when they close the lid on their laptop or press the power button.
This function does not stop the screen saver from executing.
Examples
// Television recording is beginning. Enable away mode and prevent
// the sleep idle time-out.
//
SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED | ES_AWAYMODE_REQUIRED);
//
// Wait until recording is complete...
//
//
// Clear EXECUTION_STATE flags to disable away mode and allow the system to idle to sleep normally.
//
SetThreadExecutionState(ES_CONTINUOUS);
Requirements
Minimum supported clientWindows 2000 Professional
Minimum supported serverWindows 2000 Server
HeaderWinbase.h (include Windows.h)
LibraryKernel32.lib
DLLKernel32.dll
See Also
Power Management Functions
SetSuspendState
SetSystemPowerState
WM_POWERBROADCAST
Send comments about this topic to Microsoft
Build date: 7/30/2009
==原始网址==http://msdn.microsoft.com/en-us/library/aa373208(VS.85).aspx\n
随便看

 

windows api函数参考手册包含2258条windows api函数文档,详细介绍nodejs、java、rust调用windows api的方法技巧,是学习windows api编程的入门中文文档。

 

Copyright © 2004-2023 Winrtm.com All Rights Reserved
京ICP备2021023879号-40 更新时间:2024/10/6 13:18:11