Search Tools Links Login

Screensaver Wallpaper


These are API calls that will allow you to change the wallpaper (instant update) and turn on the screensaver. I looked for examples of this on PCS and never found any that worked. These do.

Original Author: David Trep

Code




Private Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, ByVal lpvParam As Any, ByVal fuWinIni As Long) As Long



Private Const SPI_SETSCREENSAVEACTIVE = 17

Private Const SPIF_UPDATEINIFILE = &H1

Private Const SPIF_SENDWININICHANGE = &H2

Private Const SPI_GETSCREENSAVETIMEOUT = 14

Private Const SPI_SETSCREENSAVETIMEOUT = 15

Private Const SPI_SETDESKWALLPAPER = 20



Private Sub ChangeWallPaper(strWP As String)

Dim ret As Long

ret = SystemParametersInfo(SPI_SETDESKWALLPAPER, 0&, strWP, SPIF_UPDATEINIFILE Or SPIF_SENDWININICHANGE)

End Sub


Private Sub ClearWallPaper()

Dim ret As Long

ret = SystemParametersInfo(SPI_SETDESKWALLPAPER, 0&, "(None)", SPIF_UPDATEINIFILE Or SPIF_SENDWININICHANGE)

End Sub


Private Function ScreenSaverActive(Value As Boolean)

Call SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, Value, 0&, SPIF_UPDATEINIFILE Or SPIF_SENDWININICHANGE)

End Function



Public Function SetScreenSaverTimeOut(ByVal NewValueInMinutes As Long) As Boolean

'Sets Screen Saver Timeout in Minutes

Dim lRet As Long

Dim lSeconds As Long

lSeconds = NewValueInMinutes * 60

lRet = SystemParametersInfo(SPI_SETSCREENSAVETIMEOUT, lSeconds, ByVal 0&, SPIF_UPDATEINIFILE + SPIF_SENDWININICHANGE)

SetScreenSaverTimeOut = lRet <> 0

End Function

About this post

Posted: 2002-06-01
By: ArchiveBot
Viewed: 94 times

Categories

Visual Basic 6

Attachments

No attachments for this post


Loading Comments ...

Comments

No comments have been added for this post.

You must be logged in to make a comment.