[英]How to disable screensaver, sleep, lock, hibernate on windows 7 or using vb.net 2010
I don't have any idea if it is possible and how can I code it. 我不知道是否有可能以及如何编码。
I have created an application that needs to run on a non-administrator account on windows 7. It won't run if the PC goes sleep/ locked/ hibernate/ on-screensaver. 我创建了一个需要在Windows 7上的非管理员帐户上运行的应用程序。如果PC进入睡眠/锁定/休眠/屏幕保护程序,它将无法运行。 So, I want to disable them programmatically using vb.net 2010. Can any one help me?
因此,我想使用vb.net 2010以编程方式禁用它们。有谁能帮助我?
By the way, I already tried to edit the power settings of the PC so it will never sleep/ hibernate, etc. But unfortunately, it keeps on sleeping after few hours. 顺便说一句,我已经尝试编辑PC的电源设置,使其永远不会进入睡眠/休眠状态。但是,不幸的是,它在几个小时后仍保持睡眠状态。 Any idea?
任何想法?
Try this: 尝试这个:
Private Const SPI_SETSCREENSAVERACTIVE As Integer = 17
Private Declare Function SystemParametersInfo Lib "user32" _
Alias "SystemParametersInfoA" (ByVal uAction As Integer, _
ByVal uParam As Integer, ByRef lpvParam As Integer, _
ByVal uWinIni As Integer) As Integer
Public Function SetScreenSaverActive(ByVal Active As Boolean) As Boolean
Dim Result As Integer = SystemParametersInfo(SPI_SETSCREENSAVERACTIVE, CInt(Active), 0, 0)
Return (Result > 0)
End Function
SetThreadExecutionState ( VB ) can be used to inform the system that it is in use. SetThreadExecutionState ( VB )可用于通知系统正在使用中。 For CD-burners and things like that you might want to use ShutdownBlockReasonCreate .
对于CD刻录机和类似的东西,您可能需要使用ShutdownBlockReasonCreate 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.