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:
Other People Are Reading
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.
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.
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.
- 20 of the funniest online reviews ever
- 14 Biggest lies people tell in online dating sites
- Hilarious things Google thinks you're trying to search for