问题描述
我看过此StackOverflow 文章和同样的事情也适用于我.为什么RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters 1, True
每次都不工作?还有其他方法可以使它起作用,而不是重复进行直到其起作用,或者是否有某种方法对其进行编码以使其起作用? .cmd
,.bat
和.ps1
很好),或者是多次运行它以使其正常工作的最佳/唯一方法
I have had a look at this StackOverflow article and the same thing applies to me. Why is it that RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters 1, True
does not work everytime? Is there some other way to make it work rather than repeating that until it works or is there some way to code it so that it works? .cmd
, .bat
and .ps1
is fine) Or is the best/only way to run it alot of times so that it works
现在,我的解决方案是多次运行直到运行.是否有其他方法可以刷新桌面墙纸而无需多次运行RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters 1, True
?
Right now my solution is to just run that multiple time until it works. Is there any other way to refresh the desktop wallpaper without running RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters 1, True
alot of times?
推荐答案
来自帮助 https://docs.microsoft.com/zh-cn/windows/desktop/api/winuser/nf-winuser-systemparametersinfow
尽管这是2001年的文档,但已从当前版本中删除.
Although this is from the 2001 documentation and has been removed from current.
REM ChangeWallpaper.bat
REM Compiles ChangeWallpaper.vb to ChangeWallpaper.exe
C:\Windows\Microsoft.NET\Framework\v4.0.30319\vbc "%~dp0\ChangeWallpaper.vb" /out:"%~dp0\ChangeWallpaper.exe" /target:winexe
pause
;ChangeWallpaper.vb
Imports System.Runtime.InteropServices
Public Module ChangeWallpaper
Public Declare Unicode Function SystemParametersInfoW Lib "user32" (ByVal uAction As Integer, ByVal uParam As Integer, ByVal lpvParam As String, ByVal fuWinIni As Integer) As Integer
Public Const SPI_SETDESKWALLPAPER = 20
Public Const SPIF_SENDWININICHANGE = &H2
Public Const SPIF_UPDATEINIFILE = &H1
Public Sub Main()
Dim Ret as Integer
Dim FName As String
Fname = "C:\Windows\Web\Wallpaper\Theme1\img1.jpg"
'This below line which is commented out takes a filename on the command line
'FName = Replace(Command(), """", "")
Ret = SystemParametersInfoW(SPI_SETDESKWALLPAPER, 0, FName, SPIF_SENDWININICHANGE + SPIF_UPDATEINIFILE)
If Ret = 0 Then Msgbox(err.lastdllerror)
End Sub
End Module
代码在这里 https://winsourcecode.blogspot.com/2019/06/changewallpaper.html
更新
这是使用它的问题
Declare Function UpdatePerUserSystemParameters Lib "User32.dll" (ByVal i As Long, ByVal b As Boolean) As long
正如您从文章中看到的那样,Rundll32为j
传递了一个hwnd(可能是0,表示Desktop是父级),而RunDll32的HInst作为了b
的布尔值,因此它将是非零值.视为真实.
As you can see from the article Rundll32 is passing a hwnd (probably 0 to say Desktop is the parent) for j
and RunDll32's HInst as a Boolean for b
, and as this will be non zero it will be treated as true.
这篇关于如何修复RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters 1,true不会每次更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!