| Article ID: | T34 |
| Date: | 5/19/99 |
| Product: | VB Guide 2.x (all versions) |
| OS: | Windows NT 4.0 |
| Problem: | How to enable / disable screen saver in Windows NT from VB |
Method
To enable or disable the screen saver, use the
SystemParametersInfo Windows API.
Here is an example on how to
use it from VB. For more information, search for Microsoft article Q126627 in
the MSDN help. You can also use the VB API Viewer to copy and paste the
declarations used in this example.
Option Explicit
Private Declare Function SystemParametersInfo Lib "user32" _
Const SPI_GETSCREENSAVEACTIVE=16
Const SPI_SETSCREENSAVEACTIVE=17
Const
SPIF_SENDWININICHANGE=&H2
Public Sub EnableScreenSaver(enable As Boolean)
End Sub
Public Function IsScreenSaverActive() As Boolean
End Function
To enable the screen saver, call
EnableScreenSaver with an argument of True.
To disable the screen saver, call
EnableScreenSaver with an argument of False.
