Setting Windows Wallpaper

Setting Windows Wallpaper

I am trying to use the API call SystemParametersInfo to change the Windows wallpaper. It works great in a Borland C program I wrote, but doesn’t work in VB. All that happens is that the wallpaper turns blue.

The API call you should have declared in VB should look like this:

Declare Function SystemParametersInfo Lib “User”(ByVal uAction As Integer, ByVal uParam As Integer, ByVal lpvParamAs Any, ByVal fuWinIni As Integer) As Integer

In this declare statement, Microsoft forgot to put a ByVal in front of lpvParam, so it wouldn’t work. Once you fix that, this example works fine:

   Dim retval As Integer   Dim iAction As Integer   Dim iParam As Integer   Dim sParam As String * 12   Dim iUpdateINI As Integer   iAction = 20   ‘ Wallpaper parameter   iParam = 0     ‘ unused, but should be set   sParam = “ARGYLE.BMP”   iUpdateINI = 3   retval = SystemParametersInfo(ByVal iAction, ByVal iParam, ByVal sParam, ByVal iUpdateINI)
Refer to the Windows 3.1 SDK for more information on the SystemParametersInfo API call. This problem with the missing ByVal is not limited to that function. It also exists in several of the functions that read Windows INI files. For the most part, every parameter needs a ByVal in it to work correctly. If you see other statements where all the fields but one have a ByVal and it does not work, try adding the ByVal first. It will probably take care of the problem.

See also  5 Tips for Working With an Onsite Interpreter

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist