Why won't this ctypes code work with Python 3.3 but will work with Python 2.7?

后端 未结 1 527
余生分开走
余生分开走 2020-11-30 11:41

So I\'m trying to make a Python 3.3 program to change the Windows desktop background using the ctypes module. I\'ve tested the following code in Python 2.7, and it worked pe

相关标签:
1条回答
  • 2020-11-30 12:46

    SystemParametersInfoA requires a 8-bit ANSI encoded input string as a parameter, which is known as mbcs encoding in Python.

    You will have to use SystemParametersInfoW in python3. This is because SystemParametersInfoW takes in a UTF-16 wide string (which is wchar_t * in C) and the ctypes library automatically converts this passed unicode argument into c_wchar_p.

    Refer the documentation for more details.

    0 讨论(0)
提交回复
热议问题