Working with the Windows Registry

drobinow at gmail.com drobinow at gmail.com
Wed Jun 25 23:31:41 EDT 2008


On Jun 25, 10:48 pm, teh_sAbEr <teh.sa... at gmail.com> wrote:
> Hi everybody. I'm trying to write a script that'll change desktop
> wallpaper every time its run. Heres what I've gotten so far:
>
> #random wallpaper changer!
> import _winreg
> from os import walk
> from os.path import exists
> from random import randint
>
> #first grab a registry handle.
> handle = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER,'Control Panel
> \Desktop',_winreg.KEY_SET_VALUE)
>
You're missing the third parameter to OpenKey.  Try:
handle = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER,
  'Control Panel\Desktop',_0, winreg.KEY_SET_VALUE)

> The problem is, every time I run it, I get an "Access Denied" error
> when it tries to execute
> _winreg.SetValueEx(), even though i've opened the key with the
> KEY_SET_VALUE mask like it said in the help docs. Could there be
> another problem or a better way to do this?




More information about the Python-list mailing list