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.