Preventing the power option Turn off Monitor?

  • Thread starter Thread starter Cross
  • Start date Start date
C

Cross

I am developing an application that will show movies. When you wach a movie,
you do not want the Power Option "Turn off monitor" to be anabled. Is there
anyway to fix this from VB.net? (note that I am not talking about the screen
saver, that is something else).

I'm very thankfull for answers, but plea, no guesses this time.
 
And...I don't think you'd want to have this be available as this could be
the source of the next new virus. I can just see it now, millions of people
complaining that they can turn their monitors off!
 
I am developing an application that will show movies. When you wach a movie,
you do not want the Power Option "Turn off monitor" to be anabled. Is there
anyway to fix this from VB.net? (note that I am not talking about the screen
saver, that is something else).

I'm very thankfull for answers, but plea, no guesses this time.

Why does a healthy system turns off the monitor while watching movie?
I think auto-turn off monitor is a power-save feature that's applied
when no resources are being used by the system, idle state.
 
No, he is asking how to PREVENET the user from turning off the monitor, not
how to turn off the monitor.
 
Thank you Patrice! I have not had time to test this yet, but yes, this seems
to be exactly what I'm looking for.
 
If there actually is a way to do this, I'd seriously re-think about doing
it. It seems to go against usability standards. Ater all, if the user
wanted to turn off their monitor while playing the movie (maybe they just
want to listen to it in a dark room?), then why should you stop them?
 
Thank you Patrice! I have not had time to test this yet, but yes, this seems
to be exactly what I'm looking for.

"Patrice" <http://www.chez.com/scribe/> wrote in message





- Show quoted text -

If i got it correct, you want to disallow users to adjust power
options such as "turn off monitor". I don't think it's present in XP
but if you have Vista there's a new group policy feature which allows
you to configure power-related options within having admin rights.

See this:

http://www.microsoft.com/technet/technetmag/issues/2006/11/VistaGPO/default.aspx

Hope this helps.
 
Thank you for all your answers, but I think that it was only Scott that
actully understod what I wanted, and led me to the solution.

Let's take this from the begining. In the Control Panel, select Power
Options. From here you can set the monttor to be automatically turned off
whenevere there has been a sertain time without any user input (very similar
to sceen saver, but that is another feature). This is great, except for when
you are watching a movie on your computer, you are usully not touching the
keyboard or the mouse, but you DO NOT want the monitor to be turned off (ok
if the movie is really bad, then perhaps automatic turning off the monitor
could be a great feature ;-) ).

So Scott lead me to the page
http://msdn2.microsoft.com/en-us/library/aa373208(VS.85).aspx , and from
that, I was able to write this VB.net module. It works!



Public Module modDisableTurnOffMonitor
Private Const ES_DISPLAY_REQUIRED As Integer = 2
Private Const ES_CONTINUOUS As Integer = -2147483648

Private Declare Function SetThreadExecutionState Lib "kernel32" (ByVal
esFlags As Integer) As Integer

Public Sub PreventPowerOptionTurnOffMonitor()
SetThreadExecutionState(ES_DISPLAY_REQUIRED + ES_CONTINUOUS)
End Sub

Public Sub RestorePowerOptionTurnOffMonitor()
SetThreadExecutionState(ES_CONTINUOUS)
End Sub
End Module
 
Actually, it was me who understood what you wanted, but it wasn't me who led
you to that link. In all honesty, it was me that advised you strongly not
to do this as I believe it goes against standard usability guidelines for
applications.
 
No sorry, it was Patrice that led me to that link (who obviously also
understood me).

My guess is that this is the right way to do this, I mean Microsoft must
have made this API for a reason. I wouldn't be suprised if this API is used
by applications like Real Player and VLC Media Player.

In my application, I will make this an option som the user do not hav to use
this if they don't like to.
 
Back
Top