如何Windows是否要休眠或挂起检测? [英] How to detect if windows is going to hibernate or suspend?

查看:491
本文介绍了如何Windows是否要休眠或挂起检测?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用

SystemEvents.PowerModeChanged += new PowerModeChangedEventHandler(
    SystemEvents_PowerModeChanged
);

Windows时暂停诉说。但我怎么知道它是否进入休眠或挂起?

to tell when Windows is suspending. But how do I know if it is going into hibernate or suspend?

是否有.NET或PInvoke的方法来做到这一点?

Is there a .Net or PInvoke method to do this?

推荐答案

您不能告诉Hibernate之间的差异,并暂停。

You can't tell the difference between hibernate and suspend.

一个详细的讨论<一个href=\"http://groups.google.com/group/microsoft.public.win32.programmer.kernel/browse_thread/thread/b5676fa9202c8b9a?pli=1\">here.

外卖消息是你的问题presupposes一个错误的二分法:它可以是冬眠,暂停或混合睡眠......而当混合睡眠的过渡,从暂停冬眠用户code甚至没有运行(事实上​​可能没有code运行时,在过渡功率损耗的情况下发生的)。

The takeaway message is that your question presupposes a false dichotomy: It can be hibernate, suspend, or hybrid sleep... and when hybrid sleep transitions from suspend to hibernate user code isn't even running (in fact there may be no code running, the transition happens in case of power loss).

所以当决定混合睡眠时,系统不知道它是否会挂起或从休眠状态恢复,它不能告诉你什么也不知道。

So when the decision to hybrid sleep occurs, the system doesn't know whether it will resume from suspend or from hibernation, and it can't tell you what it doesn't know.

这篇关于如何Windows是否要休眠或挂起检测?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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