• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 211
  • Last Modified:

To change the desktop background picture

I want to know that whether i can change the background picture in my desktop using Visual Basic coding.
0
senthil_vivek
Asked:
senthil_vivek
1 Solution
 
Erick37Commented:
Here's how:

Option Explicit

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_SETDESKWALLPAPER = 20
Private Const SPIF_SENDWININICHANGE = &H2
Private Const SPIF_UPDATEINIFILE = &H1

Sub SetWallpaper(ByVal FileName As String)
    Dim lRet As Long
    lRet = SystemParametersInfo(SPI_SETDESKWALLPAPER, _
        0&, FileName, SPIF_SENDWININICHANGE Or SPIF_UPDATEINIFILE)
End Sub

Private Sub Command1_Click()
    'Usage
    SetWallpaper "c:\windows\tiles.bmp"
End Sub
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now