Automatically replace wallpaper

zhaozj2021-02-17  51

Every time you turn it on, you will have a monotonous boring. Is it possible to give you an unexpected surprise when it is turned on, automatically replace the wallpaper? The author uses VB 5.0 to compose a small program to easily solve this problem. And the key is the use of a Windows API function. The function of this function is used to set or ask the system range parameters, its expression form is as follows: Declare Function SystemParametersInfo LIB "User32" Alias ​​"SystemParametersInfoa" (Byval Upram As long, byval lpvparam as a, byval fuwini as long) As long 1. The first parameter uaction is used to operate, the parameter is set, and there are about 80 different parameter settings, which are set. The parameters of the wallpaper are SPI_SETDESKWALLPAPER = 20. 2. The setting of the second parameter UPARAM is corresponding to the settings of the first parameter. Here the null value. 3, the third parameter lpvparam is used to set the picture path to replace it. The setting of this parameter is also adjusted accordingly with the first parameter. 4, the fourth parameter FULWINI specifies whether the user setting parameters should be updated when setting the system parameters. Can be zero (prohibition update), or any of the following parameters: SPIF-UpdateInifile: Update the user profile in WIN.INI and registry. SPIF-SendWiniChange: If spif-updateinifile is also set, send a WM-WinInichange message to all applications, otherwise there is no effect. This message tells the application that has changed the user configuration settings. The specific implementation of the automatic replacement wallpaper is as follows: 1. Start VB, select Standard.exe to create a new project, delete Form1, add a module (module1). 2, in the module code window fill code as follows: (Suppose the wallpaper file is named 1-20 in the D: JX directory, automatically extract the wallpaper each time the wallpaper) private const spi_setdeskwallpaper = 20 private const spif_sendwiniChange = & h2 private const spif_updateinifile = & H1 Private Declare FunctionSystemParametersInfo Lib "user32" Alias ​​"SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, ByVal lpvParam As Any, ByValfuWinIni As Long) As Long Sub Main () Dim myvalue SPIFlags% = () Ramdomize myvalue = 20 * Rnd bmpfiles  = "d: jxx" CSTR (int (1 myvalue)) ". BMP" RET & = SystemParametersInfo (SPI_SETDES KWALLPAPER, 0, BYVAL BMPFILES, SPIFLAGS) End Sub 3, generate executable under the file menu, and Tell the executable into the startup directory.

转载请注明原文地址:https://www.9cbs.com/read-29298.html

New Post(0)