2
import os 
import ctypes 
path =r"C:\pathtoimage"
ctypes.windll.user32.SystemParametersInfoW(20,0,path",0)

if i run this code everthing runs smoothly the wallpaper changes, but if i do this

import os 
import ctypes 

path = os.path.abspath("image")
ctypes.windll.user32.SystemParametersInfoW(20,0,path,0)

the screen becomes black . Why does it happen if in bot examples i am giving a string as an argument.

  • You should check 1st [\[SO\]: C function called from Python via ctypes returns incorrect value (@CristiFati's answer)](https://stackoverflow.com/questions/58610333/c-function-called-from-python-via-ctypes-returns-incorrect-value/58611011#58611011). Also what's preventing you from `print(path)` and compare the 2? Please show actual filenames, as the error is most likely an invalid image name (in *%SystemRoot%*) returned by *abspath*. – CristiFati Apr 23 '21 at 13:15

0 Answers0