简体   繁体   中英

Programmatically change Windows power settings

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.

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...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM