I use the solution provided in this post to change the Windows desktop wallpaper from Python
In particular here is the code sample
import ctypes
import os
image_file = "myimage.jpg"
print("Setting the wallpaper")
SPI_SETDESKWALLPAPER = 20
ctypes.windll.user32.SystemParametersInfoW(SPI_SETDESKWALLPAPER, 0, os.path.abspath(image_file) , 0)
The problem is that the change is non persistent, in the sense that the desktop wallpaper gets reset whenever I restart my PC. How can I persistently change the Windows desktop wallpaper from Python?
I use python 3.5
user32 = ctypes.WinDLL('user32', use_last_error=True)instead ofctypes.windll.user32. Check for success and if notraise ctypes.WinError(ctypes.get_last_error()), so that the caller can handle the exception instead of blindly pretending that everything is fine.fWinIniparameter ofSystemParametersInfo.winuser.hit is defined as equal to 1. Is it correct to assume that this value will never change in future versions although it is not specified in the documentation?