How to Use Windows API to Change the Desktop Background Using VB6

Written by jim campbell
  • Share
  • Tweet
  • Share
  • Email

Programmers who create desktop backgrounds must include an installation program that changes the Windows wallpaper. You can use the Windows API to change the background using Visual Basic 6. The VB6 code calls the Windows API and specifies the new background, which must be an image file located on the computer.

Skill level:


  1. 1

    Click the Windows "Start" button and select "All Programs." Click "Microsoft.NET," and then click "Visual Studio." In the list of VB project file names, double-click the one that you want to use to change the background.

  2. 2

    Copy and paste the following code at the top of the VB6 code file:

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

    This line of code is the call to the Windows API. Adding this code adds the function to change the background.

  3. 3

    Set the new picture. Copy and paste the following code into the file:

    SavePicture pPicture, "C:\pictures\changewallpaper.bmp"

    Change the "changewallpaper.bmp" image file name with your own. You must include the file's path on the hard drive and the name of the file.

Don't Miss

  • All types
  • Articles
  • Slideshows
  • Videos
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the site, you consent to the use of cookies. For more information, please see our Cookie policy.