Programmatically change Windows power settings

一笑奈何 提交于 2019-11-28 09:21:46

问题


Is it possible to change the power-saving behaviour of a laptop computer on lid close from hibernate/standby/shutdown to Do Nothing from the .NET Framework?

Edit: it would appear that by setting the value to Standby and blocking the standby from my application, the lid close event can be detected, which is what I'm really after.

I found this question which deals with detecting lid close, but it boils down to using a standby event or writing a driver.


回答1:


Yes, you can use the WMI classes.

Take a look here to an introduction to WMI

Note that you can also use Application.SetSuspendState, but this method only allows you to suspend or hibernate. So I guess it doesn't match your needs...

About the lid, there seems to be a way to detect if the lid is closed or not...



来源:https://stackoverflow.com/questions/3802301/programmatically-change-windows-power-settings

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!