是否有一种优雅的授权方式可以让程序禁用Windows的睡眠模式? [英] Is there an elegant, authorized way for a program to disable Windows' sleep modes?

查看:88
本文介绍了是否有一种优雅的授权方式可以让程序禁用Windows的睡眠模式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不是程序员所以请耐心等待...

I am not a programmer so please bear with me...

我想开发(外包)基于Java的Windows程序,该程序在启动时加载然后坐在系统中定期监视当地天气。

I would like to develop (outsource) a Java-based Windows program that loads at boot-up and then sits in systray where it periodically monitors local weather.

然而,当计算机进入睡眠模式或混合睡眠时,根据设置,我的程序不会停止工作吗?

However, when the computer goes into sleep mode or hybrid sleep, per the settings, won't my program stop working?

假设答案是肯定的,那么在程序安装期间或程序每次启动时加载程序时,是否有官方的,Windows批准的程序禁用睡眠模式?

Assuming the answer is yes, is there an official, Windows-approved way for the program to disable the sleep modes, either during program installation or each time the program loads at boot-up?

我见过其他论坛的帖子讨论了不合理的解决方法,例如移动光标或定期ping,以便PC永远不会进入睡眠模式。但我宁愿我的程序使用标准编码禁用睡眠模式,最好由Windows / Microsoft
API或TOS批准或允许。

I've seen posts in other forums discuss inelegant work-arounds like moving the cursor or pinging periodically so the PC never enters sleep mode. But I'd rather my program disable sleep modes using standard coding, preferably approved or allowed by the Windows/Microsoft API or TOS.

我知道睡眠模式和电源管理很重要,但Windows肯定会考虑另一个程序需要禁用睡眠模式以执行其自身重要功能的时间。否则,为什么首先暂时禁用睡眠模式,
对吧?

I know sleep mode and power management are important, but surely Windows contemplates times when another program needs to disable sleep mode to perform its own important functions. Otherwise, why allow sleep mode to be temporarily disabled in the first place, right?

有人能指出我正确的方向所以我可以将信息传递给我的程序员吗?请不要移动光标式解决方案。

Can someone point me in the right direction so I can pass the information along to my programmer? Please, no move-the-cursor-style solutions.

次要问题,如果我的程序每隔5分钟监控一次当地天气,为什么单独的活动不能让PC进入睡眠状态模式?活动(移动光标)是否必须是Windows系统或与实用程序相关的,以防止睡眠
模式?

Secondary question, if my program monitors the local weather every 5 minutes, why doesn't that activity alone keep the PC from entering sleep mode? Does the activity (moving the cursor) have to be Windows system or utility-related for it to forestall sleep mode?

或者我的假设是错误的,我的程序必须是,事实上,由于它在系统托盘中处于活动状态,所以要阻止睡眠模式吗?

Or is my assumption wrong and my program must, in fact, be forestalling sleep mode since it's active in the systray?

B2BZone

推荐答案

你的程序不应该控制它。设备的所有者可以确定设备是否进入休眠状态,并且除了设备中的电源设置之外,他们不需要做任何其他操作。如果您的程序
尝试复制已存在的内容,则设备所有者可能会感到困惑。

Your program should not control that. The owner of the device can determine whether the device goes to sleep and they don't need anything more to do that than the power settings in the device. It might be confusing to the owner of the device if your program attempts to duplicate what already exists.

但是,您可以在睡眠模式之前和之后执行一些特殊操作。如果程序可以处理窗口消息,那么它应该收到

WM_POWERBROADCAST消息
,否则WMI $ b可以使用$ b Win32_PowerManagementEvent类

You can however do something special before and after a sleep mode. If the program can process window messages then it should receive WM_POWERBROADCAST messages otherwise the WMI Win32_PowerManagementEvent class can be used.


这篇关于是否有一种优雅的授权方式可以让程序禁用Windows的睡眠模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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