如何防止屏幕保护程序和我的程序执行期间睡眠? [英] how do i prevent screen-savers and sleeps during my program execution?

查看:417
本文介绍了如何防止屏幕保护程序和我的程序执行期间睡眠?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Win7上运行的c ++程序中,有没有办法伪造一个鼠标移动或类似的东西,只是为了保持屏幕保护程序不启动和系统进入睡眠?我正在寻找最小的方法,我不喜欢使用.NET。
感谢,
-nuun

In a c++ program run on Win7, is there a way to fake a mouse movement or something like that, just to keep the screen saver from starting and the system from going to sleep? I'm looking for the minimal approach and I prefer not to use .NET. Thanks, -nuun

推荐答案

不要混淆屏幕保护程序设置,使用< =http://msdn.microsoft.com/en-us/library/aa373208%28VS.85%29.aspx> SetThreadExecutionState 。这是用于通知窗口您的应用程序是活动的API的API:

Don't mess with the screensaver settings, use SetThreadExecutionState. This is the API for informing windows on the fact that your application is active:


允许应用程序通知
系统它正在使用中,从而
防止系统进入
睡眠或关闭显示器而
应用程序正在运行。

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.


多媒体应用程式,例如影片
播放器和简报应用程式,
必须使用ES_DISPLAY_REQUIRED当他们
长时间显示视频
没有用户输入

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

这篇关于如何防止屏幕保护程序和我的程序执行期间睡眠?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆