为什么这个批处理文件无法更改壁纸(Windows 7)
我有一个运行(没有错误)的脚本来更改桌面壁纸。唯一的问题是它不会改变壁纸。适当更改注册表项,以便位正常工作。只是重新加载不起作用。
:: Configure Wallpaper
REG ADD "HKCU\Control Panel\Desktop" /V Wallpaper /T REG_SZ /F /D "C:\Users\greynolds\AppData\Roaming\APOD Wallpaper\apod_wallpaper1.png"
REG ADD "HKCU\Control Panel\Desktop" /V WallpaperStyle /T REG_SZ /F /D 0
REG ADD "HKCU\Control Panel\Desktop" /V TileWallpaper /T REG_SZ /F /D 2
:: Make the changes effective immediately
%SystemRoot%\System32\RUNDLL32.EXE user32.dll, UpdatePerUserSystemParameters
I have a script that runs (without error) to change the desktop wallpaper. The only problem is that it doesn't change the wallpaper. The registry entry is changed appropriately, so that bits working. Just the reloading is not working.
:: Configure Wallpaper
REG ADD "HKCU\Control Panel\Desktop" /V Wallpaper /T REG_SZ /F /D "C:\Users\greynolds\AppData\Roaming\APOD Wallpaper\apod_wallpaper1.png"
REG ADD "HKCU\Control Panel\Desktop" /V WallpaperStyle /T REG_SZ /F /D 0
REG ADD "HKCU\Control Panel\Desktop" /V TileWallpaper /T REG_SZ /F /D 2
:: Make the changes effective immediately
%SystemRoot%\System32\RUNDLL32.EXE user32.dll, UpdatePerUserSystemParameters
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
UpdatePerUserSystemParameters 是一个未记录的函数 AFAIK
ReactOS 定义它为:BOOL WINAPI UpdatePerUserSystemParameters(DWORD dwReserved,BOOL Enable)
该函数定义意味着它不是可以使用 RunDll32 调用的函数(您最终会传递函数的随机参数)
UpdatePerUserSystemParameters is a undocumented function AFAIK
ReactOS defines it as: BOOL WINAPI UpdatePerUserSystemParameters(DWORD dwReserved,BOOL Enable)
That function definition means that it is not a function you can call with RunDll32 (You end up passing random parameters to the function)
下面是如何调用此函数,但最好使用记录的 API:
Here how you call this function but better to use documented API:
截至撰写本文时(根据我的经验),设置
HKCU\Control Panel\Desktop
通常是行不通的。最好的解决方案是调用 win32 api 函数
SystemParametersInfoSetWallpaper
- 它每次都有效。我发现这个 powershell 模块/片段非常有用 https://gallery .technet.microsoft.com/scriptcenter/Change-window-borderdesktop-609a6fb2As of this writing (in my experience) setting up
HKCU\Control Panel\Desktop
more often would not work.The best solution is to call win32 api function
SystemParametersInfoSetWallpaper
- it works every time. I found this powershell module/snippet to be quite helpful https://gallery.technet.microsoft.com/scriptcenter/Change-window-borderdesktop-609a6fb2