0

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. So, I want to disable them programmatically using vb.net 2010. Can any one help me?

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. Any idea?

Kris Edison
  • 109
  • 1
  • 4
  • 12

2 Answers2

0

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
Vinod
  • 4,672
  • 4
  • 19
  • 26
0

SetThreadExecutionState (VB) can be used to inform the system that it is in use. For CD-burners and things like that you might want to use ShutdownBlockReasonCreate.

Community
  • 1
  • 1
Anders
  • 97,548
  • 12
  • 110
  • 164