[Tutor] Registry Stuff

Andrey Ivanov ai2009 at yandex.ru
Wed Dec 22 12:42:22 CET 2004


[Jacob S.]
> Hi,

>     A little while ago, someone posted a message about an error and
> something about modifying the windows registry key HKEY_CURRENT_USER\Control
> Panel\Desktop so that the value Wallpaper was changed periodically. I wonder
> if anyone could tell me how to do that? I tried something, and it didn't
> work, and the documentation on _winreg is not very helpful to me. Any help
> is appreciated. : )

> Jacob Schmidt

> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor

Here's the code:

import sys
import os
import _winreg

key = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, \
        r"Control Panel\Desktop", 0, _winreg.KEY_ALL_ACCESS)
_winreg.SetValueEx(key, "Wallpaper", 0,_winreg.REG_SZ, \
        os.path.abspath(sys.argv[1]))

It  has  one  defect  though.  You'll  need to logout/login or restart
Windows  to  apply  the  changes.  I  don't  know  how  to  apply them
immediately.

-- 
Andrey



More information about the Tutor mailing list