我正在为自己做一个小项目,结果碰壁了。我需要更改64位Windows 10的桌面背景。我尝试使用下面的脚本来更改基于本地图像的背景。代码执行时没有错误,但是桌面变黑了。我仔细检查了一下,我的图像在c:\CuratedWallpaper\Mario.bmp,所以这不是问题所在。
import ctypes
directory = "c:\CuratedWallpaper"
imagePath = directory + "\Mario.bmp"
def changeBG(imagePath):
SPI_SETDESKWALLPAPER = 20
ctypes.windll.user32.SystemParametersInfoA(SPI_SETDESKWALLPAPER, 0, imagePath , 0)
return;
changeBG(imagePath)发布于 2017-04-22 16:17:27
我使用SystemParametersInfoW而不是SystemParametersInfoA,如下所示:
ctypes.windll.user32.SystemParametersInfoW(20, 0, path, 3)
这是ANSI与UNICODE路径字符串的问题。
我在windows10下也能用。
https://stackoverflow.com/questions/40941167
复制相似问题