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.

Share the Post:
Share on facebook
Share on twitter
Share on linkedin


The Latest

homes in the real estate industry

Exploring the Latest Tech Trends Impacting the Real Estate Industry

The real estate industry is changing thanks to the newest technological advancements. These new developments — from blockchain and AI to virtual reality and 3D printing — are poised to change how we buy and sell homes. Real estate brokers, buyers, sellers, wholesale real estate professionals, fix and flippers, and beyond may

man on floor with data

DevX Quick Guide to Data Ingestion

One of the biggest trends of the 21st century is the massive surge in internet usage. With major innovations such as smart technology, social media, and online shopping sites, the internet has become an essential part of everyday life for a large portion of the population. Due to this internet

payment via phone

7 Ways Technology Has Changed Traditional Payments

In today’s digital world, technology has changed how we make payments. From contactless cards to mobile wallets, it’s now easier to pay for goods and services without carrying cash or using a checkbook. This article will look at seven of the most significant ways technology has transformed traditional payment methods.