Question : VB .Net -- Changing the desktop background image

Tyring to change the desktop image from a VB app.

I'd like to grab an image (.JPG) from the web (specific image) and make that image the windows desktop image.  Ideally the program would run in the background and update the image based on a timer.

I found code for W95 but it doesn't seem to work with 2000/XP.

Thanks!

Answer : VB .Net -- Changing the desktop background image

You will need to use the Win32 APi SystemParametersInfo to do this.

Declare Function SystemParametersInfo _
        Lib "user32.dll" _
        Alias "SystemParametersInfoA" _
       (ByVal uAction As Integer, _
        ByVal uParam As Integer, _
        PStr)> ByVal lpvParam As String, _
        ByVal fuWinIni As Integer) As Integer

    Const SPI_SETDESKWALLPAPER As Integer = 20

    Private Sub ChangeWallPaper()

        SystemParametersInfo( _
            SPI_SETDESKWALLPAPER, _
            0, _
            "some.gif", _
            1)

    End Sub

You might need to call RedrawWindow API to see the changes though.
Random Solutions  
 
programming4us programming4us