Changing Wallpaper - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Changing Wallpaper

Wazzup guys??!

How can I change the picture that is being used as background in windows, using Visual Basic 6??

Thanks...!!

DennisTheMenace

Comments

  • MicroDotMicroDot Posts: 142Member
    : Wazzup guys??!
    :
    : How can I change the picture that is being used as background in windows, using Visual Basic 6??
    :
    : Thanks...!!
    :
    : DennisTheMenace
    :
    Hi Dennis,
    Use SystemParametersInfo API call to change the wallpaper.
    Try this snippet:

    [code]

    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_UPDATEINIFILE = &H1
    Private Const SPIF_SENDWININICHANGE = &H2

    'strImage is the name including path to the imagefile
    Private Function SetWallpaper(ByVal strImage As String) As Boolean

    On Error GoTo SW_Err

    SetWallpaper = False
    If Dir(strImage, vbNormal) <> vbNullString Then
    SetWallpaper = SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, strImage, SPIF_UPDATEINIFILE Or SPIF_SENDWININICHANGE)
    Else
    MsgBox strImage & " does not exist", vbExclamation, "Error"
    End If

    Exit Function

    SW_Err:
    Debug.Print "Error in 'SetWallpaper': " & Err.Description
    SetWallpaper = False
    End Function

    [/code]


    [hr]

    [b][blue]//MicroDot[/blue][/b]

  • dionisis84dionisis84 Posts: 69Member
    Thanks a lot m8!!!

Sign In or Register to comment.