[highlight=vbnet]Class Wallpaper
Private Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" (ByVal uAction As Integer, ByVal uParam As Integer, ByVal lpvParam As String, ByVal fuWinIni As Integer) As Integer
Private Const SPI_SETDESKWALLPAPER = 20
Private Const SPIF_UPDATEINIFILE = &H1
Dim pic As New PictureBox
Public Sub New(ImagePath as string)
Dim a As New PictureBox
Dim imagePath1 As String = Application.StartupPath & "\myNewWallpaper.bmp"
a.Image = Image.FromFile(ImagePath)
a.Image.Save(imagePath1, ImageFormat.Bmp)
SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, imagePath1, SPIF_UPDATEINIFILE)
My.Computer.FileSystem.DeleteFile(imagePath1)
End If
End Sub
End Class[/highlight]
This class is working. Created for simplex. Made few changes so you can easily call New method.
Usage:
[highlight=vbnet]Dim WallClass As New WallPaper("C:\SetThisAsWallPaper.jpg")[/highlight]
Tested. It's Working.