Activate/Deactivate Screen Saver
With this source code you can activate/deactivate the screen saver. It's useful if you don't want that the screen saver will start running when your application is running. When the user close your application you can activate the screen saver again.
Form Code
Private Const SPI_SETSCREENSAVEACTIVE = 17
Private Const SPIF_UPDATEINIFILE = &H1
Private Const SPIF_SENDWININICHANGE = &H2
Private Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" _
(ByVal uAction As Long, ByVal uParam As Long, ByVal lpvParam As Long, _
ByVal fuWinIni As Long) As Long
Public Function ActivateScreenSaver(Active As Boolean) As Boolean
Dim retval As Long
Dim ActiveFlag As Long
ActiveFlag = IIf(Active, 1, 0)
retval = SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, ActiveFlag, 0, 0)
ActivateScreenSaver = retval > 0
End Function
Private Sub Form_Load()
'the line code below will deactivate the screen saver. if you want
'to activate the screen saver, change the 'False' below to 'True'
ActivateScreenSaver (False)
End Sub
Eric De Decker
vbg.be@vbgroup.nl
License And Copy Protection AxtiveX.
Download Demo version on my Site: